0

Possible Duplicate:
Show the original branch for a commit

I am trying to figure out what happened to a specific file in our Git repo. The file's change history includes changes on several branches and some merges.

Unfortunately, the best output I can get from git log ... myfile.cs simply shows a graph of changes with not so much as a single branch name anywhere. It would be great if I could see which branch a given change was committed to.

It appears that this might be something that Git doesn't track. If so, how else might I figure out which branch a change was committed to? If I'm mistaken, how do I persuade git log to show the branch names?

(for the record, --decorate doesn't do it, presumably because this option only decorates the last change on each branch)

Community
  • 1
  • 1
Roman Starkov
  • 59,298
  • 38
  • 251
  • 324

1 Answers1

1

Possible duplicate : Show the original branch for a commit


Given the numerous operations that can happen to a commit (amend, merge, rebase, imported from origin...), I don't think you can find exactly what you want.

From other SO questions (see here or here), you can have the branches a commit belongs to :

git branch --contains <commit>
Community
  • 1
  • 1
LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • In other words, any workflow in which I expect to know the name of the branch at a later stage is doomed to fail in Git? – Roman Starkov Sep 28 '12 at 14:05
  • I'd rather say : you can always find actions which would break this logic. If you stick to a standard, you can have what you want. A 2 secs idea : add a pre-commit hook which automatically adds the current branch's name to the commit message - I haven't thought about the details, rebasing with such a rule could have some funny effects... – LeGEC Sep 28 '12 at 14:09
  • Thanks. Need to shake my Mercurial habits if I am to keep my hair and sanity... – Roman Starkov Sep 28 '12 at 14:13