Created
February 24, 2012 14:11
-
-
Save sos4nt/1901171 to your computer and use it in GitHub Desktop.
Extracts changed files from a specified commit into an output directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
usage() { | |
echo "usage: git-extract.sh commit output-directory" | |
} | |
extract() { | |
FILES=`git diff-tree --oneline --no-commit-id --name-only -r $1` | |
for file in $FILES | |
do | |
dirname=`dirname "$file"` | |
`mkdir -p "$2/$dirname"` | |
`cp "$file" "$2/$file"` | |
done | |
} | |
if [ $# -ne 2 ] | |
then | |
usage | |
exit 1 | |
else | |
extract $1 $2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment