Skip to content

Instantly share code, notes, and snippets.

@riterrani
Created June 28, 2017 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riterrani/76b795f3dd39597e5ba42b1fb3f61e4c to your computer and use it in GitHub Desktop.
Save riterrani/76b795f3dd39597e5ba42b1fb3f61e4c to your computer and use it in GitHub Desktop.
#!/bin/bash
# Target directory
TARGET=$3
echo "Finding and copying files and folders 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 "Files copied to target directory";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment