118

This question is closely related to List all commits for a specific file however it is different. I want to find out which commits, across all branches, had modified a given file.

To make it more complex, the given file may or may not be in the working tree.

Community
  • 1
  • 1
Saurabh Nanda
  • 6,373
  • 5
  • 31
  • 60

3 Answers3

147

Try this:

git log --all -- path
manojlds
  • 290,304
  • 63
  • 469
  • 417
57

Command line

I would highly recommend to add the graph option with git log:

git log --graph --all -- <filename>

git log --graph --all -- <filename>

Gui

Gitk is an pretty old tool and not always installed, I recommend a different free tool like e.g. SourceTree:

SourceTree

jaques-sam
  • 2,578
  • 1
  • 26
  • 24
  • 8
    How to log a file and show its branch graph in SourceTree? Right click on a file and select "Log Selected..." doesn't show history on all branches. – aleung Mar 13 '17 at 08:45
56

You can use gitk

gitk --all <path to file> (you need to install gitk)

e.g.

gitk --all -- /home/kit.ho/project/abc.txt

TheOneTeam
  • 25,806
  • 45
  • 116
  • 158
  • 1
    I don't know why my answer was downvoted, but yours doesn't consider that the question specifically asks for log across all branches. You are just giving answer that the OP has already linked to. – manojlds Sep 19 '11 at 06:01
  • 2
    I wasn't a downvoter, but this needs an `--all` or something similar to go across more history than the current branch. – wjl Sep 19 '11 at 18:50
  • Why the downvotes? This works perfectly fine. Both the answers are correct. One works for the text console, the other for the gitk GUI. Can I mark both correct? – Saurabh Nanda Sep 20 '11 at 14:20
  • @Saurabh Nanda: Mark the one you think is useful for you. – TheOneTeam Sep 20 '11 at 14:31
  • 1
    @saurabh - This answer has been editted. Kit Ho - Mention that you are editting. And makes it look as though both answers were originally correct. – manojlds Sep 20 '11 at 14:56