2

Possible Duplicate:
Show the original branch for a commit

git version 1.7.4.1

I have about 4 different branches and have been merging them.

However, I make some changes about a week ago and in the git log I can see the commit. But I doesn't tell me what branch that commit was committed on.

I have tried the following:

git log --decorate=full

But didn't give me too much information.

And I have tried

git branch --contains <commit hash>

But that doesn't tell me the origin of the commit

Many thanks for any suggestions,

Community
  • 1
  • 1
ant2009
  • 27,094
  • 154
  • 411
  • 609
  • what's the output of `git branch --contains `? – CharlesB Jul 14 '11 at 11:05
  • I doubt this is programming-releated. Maybe linux releated? – genesis Jul 14 '11 at 11:06
  • 2
    @genesis definitely programming related, as it deals with git, a programming tool – CharlesB Jul 14 '11 at 11:07
  • @charles, I just get a list of branches that have that commit after a merge. I was hopping to get the origin of that commit. Thanks. – ant2009 Jul 14 '11 at 11:09
  • Just posted an [answer](http://stackoverflow.com/questions/4535251/show-the-original-branch-for-a-commit/6692500#6692500) on the original question! Tell me if it works for you – CharlesB Jul 14 '11 at 11:35
  • 1
    Posted a much better [answer](http://stackoverflow.com/questions/4535251/show-the-original-branch-for-a-commit/6693079#6693079): it's in the message of the last commit of `git log ..master --merges` – CharlesB Jul 14 '11 at 12:26

1 Answers1

2

No, there is not.

The branch names are (at least by most git developers) generally considered to be transient, private to developer and meaningless after the branch is closed.

I believe the same is the case in mercurial, but not in bazaar, which IIRC remembers the name in the commit data.

Jan Hudec
  • 73,652
  • 13
  • 125
  • 172
  • found it was possible, see linked answer in question's comment! – CharlesB Jul 14 '11 at 12:27
  • @CharlesB: Actually in general case it's not. If you have the reflog, you know, but you only have that on the repository where the commit was created and it normally expires after some time. If you at least still have the branch, you can usually guess correctly, but most people delete branches they merged and pushed and even reuse the names after time. – Jan Hudec Jul 14 '11 at 13:19
  • Yes but most of the times merge commits are kept, so you can see the branch name in it (that's the idea of my answer) – CharlesB Jul 14 '11 at 13:28
  • @CharlesB That only works if there is a merge commit, which there won't be in the case of fast-forward merges. – user229044 Jul 14 '11 at 19:55
  • @CharlesB: It depends. If you use [git flow](http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/) (and therefore merge to trunk --no-ff), the merge commits are there and have defined order of parents, so they make sense (that's the reason for those git flow rules). But if you simply merge and push, the fast-forwards and the fact that you'll often merge master to topic and not the other way round will make the method about completely useless. – Jan Hudec Jul 15 '11 at 08:45
  • @Jan agree, I haven't thought about ff-merges because I never use them, exactly because of the exposed problem: it's better to *see* that a feature has been merged – CharlesB Jul 15 '11 at 08:51