Skip to content

Instantly share code, notes, and snippets.

@kriscarle
Forked from revathskumar/git-copy-sample.sh
Last active August 29, 2015 13:55
Show Gist options
  • Save kriscarle/8700599 to your computer and use it in GitHub Desktop.
Save kriscarle/8700599 to your computer and use it in GitHub Desktop.
./git-copy.sh aabb37fc243675de1194e38f75a554695ed3c111 7b6efc6a0731d0da7ce0d13b19098db2f7da224b ../uploads
#!/bin/bash
# Target directory
TARGET=$3
echo "Coping to $TARGET"
echo -e "Changes between $1 and $2 \n\r" > "$TARGET/README.txt"
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"
echo -e "$i \n\r" >> "$TARGET/README.txt"
done
echo "Done";
@kriscarle
Copy link
Author

updated to also write a list to README.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment