{"thread":{"id":"21968","subject":"How do I show only log messages for commits on a specific branch?","startedAt":"2009-12-16T10:16:47Z","lastAt":"2009-12-17T15:04:03Z","messageCount":10,"participants":["bd@bc-bd.org","Elijah Newren","Miklos Vajna","Santi Béjar","David Roden","Stefan Völkel","Pat Notz"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"129988","messageId":"20091216101647.GB27373@bc-bd.org","threadId":"21968","inReplyTo":null,"subject":"How do I show only log messages for commits on a specific branch?","fromName":"","fromEmail":"bd@bc-bd.org","sentAt":"2009-12-16T10:16:47Z","receivedAt":"2009-12-16T10:16:47Z","isPatch":false,"sender":{"key":"bd@bc-bd.org","avatar":null},"body":"Hello list,\n\n[ git v1.6.3.3 ]\n\nimagine this:\n\n\t     --A--*--B (new)\n\t    /\n\t*--X--*--Y (master)\n\nNow I'd like to list only log messages for A..B (X..B would be okay too).\n\nI know of \n\n\tgit log master..new\n\nhowever then I need to remember that I branched new of master, and to be honest,\nsometimes I forget.\n\nSo how do I:\n\n\tgit please-tell-me-the-branch-I-started-this-branch-from new\n\nThanks in advance,\n\n\tStefan\n\n-- \nBOFH excuse #181:\n\nAtilla the Hub\n"},{"id":"129997","messageId":"51419b2c0912161005n1596d4a1n92ed555c98aee4c6@mail.gmail.com","threadId":"21968","inReplyTo":"20091216101647.GB27373@bc-bd.org","subject":"Re: How do I show only log messages for commits on a specific branch?","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2009-12-16T18:05:52Z","receivedAt":"2009-12-16T18:05:52Z","isPatch":false,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Wed, Dec 16, 2009 at 3:16 AM,  <bd@bc-bd.org> wrote:\n> imagine this:\n>\n>             --A--*--B (new)\n>            /\n>        *--X--*--Y (master)\n>\n> Now I'd like to list only log messages for A..B (X..B would be okay too).\n>\n> I know of\n>\n>        git log master..new\n>\n> however then I need to remember that I branched new of master, and to be honest,\n> sometimes I forget.\n>\n> So how do I:\n>\n>        git please-tell-me-the-branch-I-started-this-branch-from new\n\nIn the above example, you technically did not create 'new' off of\n'master', you created new starting at X.  You may think of it in terms\nof branching off of 'master', but\n  git branch new master\nresolves 'master' to the commit it points at and creates 'new'\npointing at that commit.  That's all that is recorded.  But I believe\nthe info you are really interested in is where new started, rather\nthan the fact that it branched off master.  Is that correct?  If so,\njust use new@{30.years.ago} (or any other sufficiently long period of\ntime):\n  git log new@{30.years.ago}..new\n(You'll get a warning that 'new' hasn't existed for 30 years but it\ndoesn't hurt anything)\n\nHope that helps,\nElijah\n"},{"id":"130004","messageId":"20091216232641.GK25474@genesis.frugalware.org","threadId":"21968","inReplyTo":"51419b2c0912161005n1596d4a1n92ed555c98aee4c6@mail.gmail.com","subject":"Re: How do I show only log messages for commits on a specific branch?","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-12-16T23:26:42Z","receivedAt":"2009-12-16T23:26:42Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Wed, Dec 16, 2009 at 11:05:52AM -0700, Elijah Newren <newren@gmail.com> wrote:\n>   git log new@{30.years.ago}..new\n> (You'll get a warning that 'new' hasn't existed for 30 years but it\n> doesn't hurt anything)\n\nThat's the same as \"git log new\", if I'm not mistaken.\n\nWhat Stefan wants to do is to let git log show the commits which are\nonly in the \"new\" branch, but I don't think there is an out-of-the-box\nsolution for that.\n\nOne solution I can think of is to iterate over each ref using \"git\nfor-each-ref --format='%(refname)' 'refs/heads/*'\", then run \"git\nmerge-base $i new\", run git rev-list $mb..new|wc -l and then you could\ndecide what is the first commit that does not belong to any other\nbranch. But that's just an idea, I don't have the motivation to script\nit properly.\n"},{"id":"130005","messageId":"adf1fd3d0912161558u36d9674eid36e3042d181ed8f@mail.gmail.com","threadId":"21968","inReplyTo":"20091216232641.GK25474@genesis.frugalware.org","subject":"Re: How do I show only log messages for commits on a specific branch?","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-12-16T23:58:47Z","receivedAt":"2009-12-16T23:58:47Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On Thu, Dec 17, 2009 at 12:26 AM, Miklos Vajna <vmiklos@frugalware.org> wrote:\n> On Wed, Dec 16, 2009 at 11:05:52AM -0700, Elijah Newren <newren@gmail.com> wrote:\n>>   git log new@{30.years.ago}..new\n>> (You'll get a warning that 'new' hasn't existed for 30 years but it\n>> doesn't hurt anything)\n>\n> That's the same as \"git log new\", if I'm not mistaken.\n>\n> What Stefan wants to do is to let git log show the commits which are\n> only in the \"new\" branch, but I don't think there is an out-of-the-box\n> solution for that.\n\nNot out-of-the-box but this does exactly what you said, print all\ncommits only reachable from the \"new\" branch:\n\ngit log new --not $(git for-each-ref --format='%(refname)'\n'refs/heads/*' | grep -v refs/heads/new)\n\nFor the original question, I think what makes most sense in this case\nis asking for the commits since the upstream branch. Some time ago\nthere was a discussion about a syntax for the tracking branch and\nthere was even a patch:\n\nSubject: [PATCH v2] Introduce <branch>@{upstream} as shortcut to the\ntracked branch\nDate: 2009-09-10 15:25:57 GMT\n\nhttp://news.gmane.org/find-root.php?message_id=%3calpine.DEB.1.00.0909101724520.8306%40pacific.mpi%2dcbg.de%3e\n\nbut it's not in git.git.\n\nHTH,\nSanti\n"},{"id":"130006","messageId":"51419b2c0912161559x4de94464pe06df2845dbe3b78@mail.gmail.com","threadId":"21968","inReplyTo":"20091216232641.GK25474@genesis.frugalware.org","subject":"Re: How do I show only log messages for commits on a specific branch?","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2009-12-16T23:59:54Z","receivedAt":"2009-12-16T23:59:54Z","isPatch":false,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Wed, Dec 16, 2009 at 4:26 PM, Miklos Vajna <vmiklos@frugalware.org> wrote:\n> On Wed, Dec 16, 2009 at 11:05:52AM -0700, Elijah Newren <newren@gmail.com> wrote:\n>>   git log new@{30.years.ago}..new\n>> (You'll get a warning that 'new' hasn't existed for 30 years but it\n>> doesn't hurt anything)\n>\n> That's the same as \"git log new\", if I'm not mistaken.\n\nDid you try it with a 'new' branch in your repository that started at\nthe beginning of history rather than at some commit?  \"git log new\"\nand \"git log new@{30.years.ago}..new\" are not the same for me with\ngit-1.6.5.5:\n\n$ git init repo\n$ cd repo\n$ echo content> foo && git add foo && git commit -mone foo\n$ echo more content >> foo && git commit -mtwo foo\n$ git checkout -b new master~1\n$ echo stuff >> foo && git commit -mthree foo\n$ git log new@{30.years.ago}..new\nwarning: Log for 'new' only goes back to Wed, 16 Dec 2009 16:48:02 -0700.\ncommit 7df8bad7cc146875c59ab030da0d25555976e79c\nAuthor: Elijah Newren <newren@gmail.com>\nDate:   Wed Dec 16 16:48:07 2009 -0700\n\n    three\n$ git log new\n\ncommit 7df8bad7cc146875c59ab030da0d25555976e79c\nAuthor: Elijah Newren <newren@gmail.com>\nDate:   Wed Dec 16 16:48:07 2009 -0700\n\n    three\n\ncommit b86eadcdb152877ade44bebf4b8742884949f29f\nAuthor: Elijah Newren <newren@gmail.com>\nDate:   Wed Dec 16 16:47:31 2009 -0700\n\n    one\n\n> What Stefan wants to do is to let git log show the commits which are\n> only in the \"new\" branch, but I don't think there is an out-of-the-box\n> solution for that.\n\nAre you sure?  I'm more inclined to believe he'd like to see all the\ncommits that have been added to the \"new\" branch since he created it\n(which may be the same as what you say, but not necessarily).  Of\ncourse, neither my assumption or yours match what he actually asked\nfor (though I think what he asked for isn't possible and is merely an\nmeans to the end he really wants).\n\nAlso, I think this does what you asked for (the commits in the \"new\"\nbranch but no other branch):\n$ git log new $(git for-each-ref --format='%(refname)' 'refs/heads/*'\n| grep -v '^refs/heads/new$' | sed -e s/^/^/)\n"},{"id":"130007","messageId":"51419b2c0912161604j4e3d6a9ft4b0e48d6ca74d5c9@mail.gmail.com","threadId":"21968","inReplyTo":"adf1fd3d0912161558u36d9674eid36e3042d181ed8f@mail.gmail.com","subject":"Re: How do I show only log messages for commits on a specific branch?","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2009-12-17T00:04:11Z","receivedAt":"2009-12-17T00:04:11Z","isPatch":false,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Wed, Dec 16, 2009 at 4:58 PM, Santi Béjar <santi@agolina.net> wrote:\n> git log new --not $(git for-each-ref --format='%(refname)'\n> 'refs/heads/*' | grep -v refs/heads/new)\n\nHow did I miss '--not' as a git log option?  Thanks for pointing it out!\n"},{"id":"130008","messageId":"20091217002024.GM25474@genesis.frugalware.org","threadId":"21968","inReplyTo":"51419b2c0912161559x4de94464pe06df2845dbe3b78@mail.gmail.com","subject":"Re: How do I show only log messages for commits on a specific branch?","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-12-17T00:20:24Z","receivedAt":"2009-12-17T00:20:24Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Wed, Dec 16, 2009 at 04:59:54PM -0700, Elijah Newren <newren@gmail.com> wrote:\n> Did you try it with a 'new' branch in your repository that started at\n> the beginning of history rather than at some commit?  \"git log new\"\n> and \"git log new@{30.years.ago}..new\" are not the same for me with\n> git-1.6.5.5:\n> \n> $ git init repo\n> $ cd repo\n> $ echo content> foo && git add foo && git commit -mone foo\n> $ echo more content >> foo && git commit -mtwo foo\n> $ git checkout -b new master~1\n> $ echo stuff >> foo && git commit -mthree foo\n> $ git log new@{30.years.ago}..new\n\nAah, thanks. Then you can just avoid the warning using\n\ngit log $(git reflog show new|sed -n 's/ .*//;$ p')..new\n\n> Are you sure?  I'm more inclined to believe he'd like to see all the\n> commits that have been added to the \"new\" branch since he created it\n> (which may be the same as what you say, but not necessarily).  Of\n> course, neither my assumption or yours match what he actually asked\n> for (though I think what he asked for isn't possible and is merely an\n> means to the end he really wants).\n\nNo, I'm not sure about what he thought, but I hope he will clarify. :)\n"},{"id":"130023","messageId":"hgct5i$fbg$1@ger.gmane.org","threadId":"21968","inReplyTo":"20091216101647.GB27373@bc-bd.org","subject":"Re: How do I show only log messages for commits on a specific branch?","fromName":"David Roden","fromEmail":"david.roden@sysart.de","sentAt":"2009-12-17T09:20:35Z","receivedAt":"2009-12-17T09:20:35Z","isPatch":false,"sender":{"key":"david.roden@sysart.de","avatar":null},"body":"bd@bc-bd.org wrote:\n\n> imagine this:\n> \n> --A--*--B (new)\n> /\n> *--X--*--Y (master)\n> \n> Now I'd like to list only log messages for A..B (X..B would be okay too).\n> \n> I know of\n> \n> git log master..new\n> \n> however then I need to remember that I branched new of master, and to be\n> honest, sometimes I forget.\n> \n> So how do I:\n> \n> git please-tell-me-the-branch-I-started-this-branch-from new\n> \n> Thanks in advance,\n\nI have had wonderful results using\n\n    git log new --not master\n\nor\n\n    git log new ^master\n\nThis is using git 1.6.4.4 and this way of specifying commits is not \nmentioned in the man page—it seems to work, though.\n\n\tDavid\n"},{"id":"130032","messageId":"4B2A3E3F.1@bc-bd.org","threadId":"21968","inReplyTo":"20091217002024.GM25474@genesis.frugalware.org","subject":"Re: How do I show only log messages for commits on a specific branch?","fromName":"Stefan Völkel","fromEmail":"bd@bc-bd.org","sentAt":"2009-12-17T14:20:47Z","receivedAt":"2009-12-17T14:20:47Z","isPatch":false,"sender":{"key":"bd@bc-bd.org","avatar":null},"body":"Hi,\n\n> git log $(git reflog show new|sed -n 's/ .*//;$ p')..new\n\nI had trouble getting the above to work as a git alias (someething wrt\nescaping I guess), however this:\n\n        gl = log --graph --pretty=oneline --abbrev-commit\n\tbl = !sh -c 'git gl $0 --not $(git for-each-ref --format=%\\\\(refname\\\\)\nrefs/heads/* | grep -v refs/heads/$0)'\n\ndoes exactly what I want:\n\n\t# git reflog show new\n\t76cacd3 new@{0}: commit: B\n\t9638379 new@{1}: commit: A\n\t7944f55 new@{2}: branch: Created from HEAD\n\n\t# git gl\n\t* 76cacd3 B\n\t* 9638379 A\n\t* 7944f55 Y\n\t* b8e4a96 X\n\n\t# git bl new\n\t* 76cacd3 B\n\t* 9638379 A\n\nThanks for the help,\n\n\tStefan\n"},{"id":"130033","messageId":"1cd1989b0912170704m4b95849agf2baaa131a1bff7c@mail.gmail.com","threadId":"21968","inReplyTo":"20091216101647.GB27373@bc-bd.org","subject":"Re: How do I show only log messages for commits on a specific branch?","fromName":"Pat Notz","fromEmail":"patnotz@gmail.com","sentAt":"2009-12-17T15:04:03Z","receivedAt":"2009-12-17T15:04:03Z","isPatch":false,"sender":{"key":"patnotz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45364?v=4"},"body":"> So how do I:\n>\n>        git please-tell-me-the-branch-I-started-this-branch-from new\n>\n\nYou may also be interested in the git show-branch command.  The output\nmay be unintuitive at first but once you grok it it's pretty useful...\nespecially if you have several branches.\n\nAside from the man page, here's a blog post the describes the output:\nhttps://wincent.com/wiki/Understanding_the_output_of_%22git_show-branch%22\n\n~ Pat\n"}]}