Christmas day treat, for those who ever want to review a specific revision of a file and manually compare with the current version with tools git does not know about, this little script is pretty useful:
Code: Select all
#!/bin/bash
if [[ "$#" != "3" ]]; then
echo Needed 3 arguments, but got $#! Usage: gitcheckoutas HASH path newFile
exit -1
fi
git checkout $1 -- $2
cp $2 $3
touch $3:$2@$1
git checkout HEAD -- $2
This assumes no change to the current file, commit it or stash it first if so.
It checks out the old version, copies it to the new name requested, touches a file as "name colon original name @ hash" as a reference so that you can see where it came from in future, in case you forget, then finally checks out the latest of the file again.
I use this to visually diff PDFs in one project, but it's often a pain in the arse if you don't want to use std diff tools to compare. Maybe hex editor or hex dump compare etc.
Enjoy!
Fred.