Created
March 13, 2012 13:47
-
-
Save revathskumar/2028858 to your computer and use it in GitHub Desktop.
Copy all chaged files with directory structure
This file contains 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
./git-copy.sh aabb37fc243675de1194e38f75a554695ed3c111 7b6efc6a0731d0da7ce0d13b19098db2f7da224b ../uploads |
This file contains 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/bash | |
# Target directory | |
TARGET=$3 | |
echo "Coping to $TARGET" | |
for i in $(git diff --name-only $1 $2) | |
do | |
# First create the target directory, if it doesn't exist. | |
mkdir -p "$TARGET/$(dirname $i)" | |
# Then copy over the file. | |
cp "$i" "$TARGET/$i" | |
done | |
echo "Done"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice script and very simple, i almost burn my brain doing the same but using a most complicated approach xD.
Here is how i dit:
https://github.com/Mayccoll/Git/tree/master/Git-Zip
In my script you only select one commit, the reason for that is because you always copy the last version of the file, so if you select commits from the middle you are not reflecting the state of the files at that moment.
Maybe i will use your approach for my script :)
Tnks