Last Updated: February 25, 2016
·
902
· timfernihough

See changes: Git Command Line Tips

Of course, most programmers are familiar with the very useful and user-friendly UI tools that Github has and I absolutely urge you to use them if you don't already - they are better than any tool I've ever used.

I recently found myself in the situation where I did not have a nice UI tool to see the changes of a series of commits (ironically enough, it was a repository not hosted on Github).

There are a couple VERY useful commands you can use to either see the diff of changes for a specific commit, or alternatively; just to see the list of files affected by the commit.

In the examples below, {commit_hash} should be replaced by the actual hash (at minimum, the first 6 characters of the hash should be sufficient).

git show {commit_hash}

will return a diff of the changes to stdout. You'll probably want to output this to a file.

git show {commit_hash} > ~/Desktop/diff.txt

or something similar will suffice if you don't want to have your terminal assaulted by what could be hundreds of lines of code.

git show --name-only {commit_hash}

will return a list of the files changed in the mentioned commit. If you're dealing with a ton of files here, you may still want to output redirect to a file but it should be easier to swallow than the diff itself.