Skip to content

Instantly share code, notes, and snippets.

@indrisepos
Forked from revathskumar/git-copy-sample.sh
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save indrisepos/d8bcd1a2acfb2e55685e to your computer and use it in GitHub Desktop.

Select an option

Save indrisepos/d8bcd1a2acfb2e55685e to your computer and use it in GitHub Desktop.
./git-copy.sh aabb37fc243675de1194e38f75a554695ed3c111 7b6efc6a0731d0da7ce0d13b19098db2f7da224b ../uploads
#!/bin/bash
# Target directory
TARGET=$3
echo "Delete files:"
for i in $(git diff --diff-filter=D --name-only $1 $2)
do
echo "$i"
done
echo "Coping to $TARGET"
for i in $(git diff --diff-filter=ACMRTUXB --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