How to view file history in Git? How to view file history in Git? git git

How to view file history in Git?


Use git log to view the commit history. Each commit has an associated revision specifier that is a hash key (e.g. 14b8d0982044b0c49f7a855e396206ee65c0e787 and b410ad4619d296f9d37f0db3d0ff5b9066838b39). To view the difference between two different commits, use git diff with the first few characters of the revision specifiers of both commits, like so:

# diff between commits 14b8... and b410...git diff 14b8..b410# only include diff of specified filesgit diff 14b8..b410 path/to/file/a path/to/file/b

If you want to get an overview over all the differences that happened from commit to commit, use git log or git whatchanged with the patch option:

# include patch displays in the commit historygit log -pgit whatchanged -p# only get history of those commits that touch specified pathsgit log path/a path/bgit whatchanged path/c path/d


Looks like you want git diff and/or git log. Also check out gitk

gitk path/to/filegit diff path/to/filegit log path/to/file


I like to use gitk name_of_file

This shows a nice list of the changes that happened to a file at each commit, instead of showing the changes to all the files. Makes it easier to track down something that happened.