Last Updated: February 25, 2016
· joshuabutner

Find Specific Revisions of Files with 'Git Show'

Lifted/slightly customized from Kenneth Kalmer's post on his blog, Open Sourcery: Pluck out an old revision of a file with git show


• Find the offending commit with 'git lg', 'git log' or 'git log -p'.

• View the file in question by:

git show SHA-ID:path/to/file

or if you're using a text editor with CLI hooks- something like this:

git show SHA-ID:path/to/file | text-editor-hook

for example, I call Sublime Text 3 from the terminal via the 'slime' command, so I would:

git show SHA-ID:path/to/file | slime

and, presto! the file appears in Sublime Text.

• Replace current copy with:

git show SHA-ID:path/to/file > path/to/file

or if you went the text editor route, then just copy the offending lines to the current file, in the text editor.

• Verify the damage has been undone with 'git diff'

• Commit

• Breathe