try-catch-FAIL

Failure is inevitable

NAVIGATION - SEARCH

Git Tips & Tricks, Part 8–See What’s Changed (again!)

I showed you one way that you can quickly see what’s changed back in Part 6 by comparing two commits.  You can also see what changed in a specific commit and fire up your git diff tool for each change.  I’ll show you how in this  post.

You can see a list of all the files that changed in a commit by getting its hash and using the ‘git show’ command:

#Get the hash of the desired commit with 'git log'
$Hash = "hash-here"
git show --pretty="format:" --name-only $Hash

This will spit out the name of each file that changed, one per line.  Here’s an example from my test repo:

image

Another command I sometimes use allows me to see details on what’s changed between two commits, one file at a time:

#Get the hash of the desired commit with 'git log'
$Hash = "hash-here"
git difftool "$Hash~1" $Hash

You’ll be given the option to view each affected file in your configured diff tool (just press enter) or to skip it and move to the next file (press ‘n’):

image

About Matt Honeycutt...

Matt Honeycutt is a software architect specializing in ASP.NET web applications, particularly ASP.NET MVC. He has over a decade of experience in building (and testing!) web applications. He’s an avid practitioner of Test-Driven Development, creating both the SpecsFor and SpecsFor.Mvc frameworks.

He's also an author for Pluralsight, where he publishes courses on everything from web applications to testing!

blog comments powered by Disqus