Last active
December 17, 2015 06:59
-
-
Save cmcenearney/5569211 to your computer and use it in GitHub Desktop.
git fun: list files changed by most recent commit, copy to dev server (or wherever)
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 | |
# list files changed by the last commit | |
# and copy them to a target dir | |
TARGET=$1 | |
MOST_RECENT=$(git log -n 1 --pretty=format:'%h') | |
PREV=$(git log --skip=1 -n 1 --pretty=format:'%h') | |
echo "Coping to $TARGET" | |
for i in $(git diff --name-only $MOST_RECENT $PREV) | |
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