Phil for Humanity Phil for Humanity
A Guide for the Survival of Humankind and Helping the World, Society, and Yourself.

Git Log and Cat-File

The Git command to display the entire history or logs of each commit is this command:

git log

The problem with this command is that it will output too much information to the terminal, so most people direct the output to a text file or an array that can searched more easily.

However, there are a few ways to limit how much data is being displayed. For instance, if you only want to see the commits from a SHA (exclusive) to another SHA (inclusive), you can run this command:

git log SHA1..SHA2

Or to view the commits from a SHA (exclusive) to HEAD (inclusive), use this command:

git log SHA..HEAD

Unfortunately, you cannot run Git log on a single SHA for some reason. To do that, you have to run this command instead:

git cat-file p SHA

Note that if any SHA has two or more parents, then it is a merge commit; thus, you must use the "-m #" arguments when cherry-picking.

Finally, to display all commits or SHAs that deleted any files, run this command:

git log --diff-filter=D --summary

To list the files deleted in a repository, just grep for lines with the string "delete mode" in it.

by Phil for Humanity
on 12/06/2012

Related Articles
 » Git Status
 » ClearCase Support: Finding ClearCase Log and Cache Files
 » Git Merge-Base: How to Get the Last Merged SHA