List all commits (across all branches) for a given file

Git

Git Problem Overview


This question is closely related to https://stackoverflow.com/questions/3701404/git-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.

Git Solutions


Solution 1 - Git

Try this:

git log --all -- path

Solution 2 - Git

You can use gitk

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

e.g.

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

Solution 3 - Git

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSaurabh NandaView Question on Stackoverflow
Solution 1 - GitmanojldsView Answer on Stackoverflow
Solution 2 - GitTheOneTeamView Answer on Stackoverflow
Solution 3 - GitDrumMView Answer on Stackoverflow