Failure is inevitable


Git Tips & Tricks, Part 6–Quickly See What’s Changed

Today’s entry includes two tips for the price of one!  I’ll show you how to use git with Powershell to see all the files that changed between two commits.  I’ll also show you a quick and easy way to determine when a particular file was removed from source control.

First, let’s pretend that you want to see all the files that changed in the last month.  Find the hash of the first commit of the month, then use the ‘git diff’ command to see what’s changed:

git diff <commit hash here> HEAD --name-only

What if you only care about JavaScript files?  Pipe the output through Powershell:

git diff <commit hash here> HEAD --name-only | sls -SimpleMatch ".js"

Another handy trick: how do you determine when a particular file was deleted?  Use ‘git log’:

git log -- /path/to/file/that/was/removed

These are simple tricks, but useful, especially when you’re doing peer reviews on a story that stretches across many commits.

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