Skip to content

Instantly share code, notes, and snippets.

@elleryq
Created August 6, 2013 09:46
Show Gist options
  • Save elleryq/6163200 to your computer and use it in GitHub Desktop.
Save elleryq/6163200 to your computer and use it in GitHub Desktop.
Get before/after files from specified commit-id.
#!/bin/bash
if [ -z $1 ]; then
echo "Need commitid."
exit -1
fi
FILES=`git diff-tree --no-commit-id --name-only -r $1`
OUTPUT='/tmp/git-diff'
mkdir -p $OUTPUT
mkdir -p $OUTPUT/before
mkdir -p $OUTPUT/after
for FILE in $FILES; do
NEW_FILENAME=`basename $FILE`
git show $1~1:$FILE > $OUTPUT/before/$NEW_FILENAME
git show $1:$FILE > $OUTPUT/after/$NEW_FILENAME
done
7za a -r ~/tmp/$1.7z $OUTPUT/*
rm -rf $OUTPUT
echo "done".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment