Created
July 25, 2017 22:09
-
-
Save triple-j/df3e0f11cfe3eca62ef5ececbbbb7b41 to your computer and use it in GitHub Desktop.
Find all the files changed/deleted since a given commit
This file contains hidden or 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 | |
OLDCOMMIT=$1 | |
OUTDIR="__UPDATES__" | |
DELETED="" | |
FILES=`git diff --name-only $OLDCOMMIT` | |
rm --force --recursive "$OUTDIR" | |
IFS=" | |
" | |
for FILE in $FILES; do | |
if [ -f "$FILE" ]; then | |
echo "Copying: $FILE" | |
mkdir --parents "$(dirname -- "$OUTDIR/$FILE")" | |
cp --force "$FILE" "$OUTDIR/$FILE" | |
else | |
echo "File no longer exists: $FILE" | |
DELETED="$DELETED $FILE\n" | |
fi | |
done | |
if [ -n "$DELETED" ]; then | |
echo "" | |
echo "Deleted Files:" | |
echo -e $DELETED | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: __git-changes.sh <OLD_COMMIT>
Run this script in a folder containing a GIT repository, and it will copy any files that have been changed between the currently checked out commit and the commit given to the script. You can find the files in the newly created
__UPDATES__
folder.A list of files that have been deleted since the given commit will be displayed in the terminal.