Created
June 19, 2018 15:05
-
-
Save solbisio/ad1e31b8bb5318dd87d28a8577c62445 to your computer and use it in GitHub Desktop.
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 | |
echo "Export Git Diff" | |
read -p "Export Start Commit ID: " input1 | |
read -p "Export End Commit ID: " input2 | |
commitIdStart="${input1}" | |
if [ "${input2}" == "" ]; then | |
commitIdEnd="HEAD" | |
else | |
commitIdEnd="${input2}" | |
fi | |
echo "Start ID: $commitIdStart" | |
echo "End ID: $commitIdEnd" | |
#Create Export Folder | |
now=$(date +%Y%m%d_%H%M%S) | |
#echo "Current date: $now" | |
dirpath="GitExport/$now" | |
echo "Export Path:$dirpath" | |
mkdir -p $dirpath | |
#Get File List | |
files=$(git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT $commitIdStart $commitIdEnd); | |
#echo $files; | |
for item in $files ; do | |
echo "Copy: $item" | |
## For Linux (Todo Test) | |
newdir=$(dirname $item) | |
mkdir -p "$dirpath/$newdir" | |
cp "$item" "$dirpath/$item" | |
# For Mac OS | |
# ditto "$item" "$dirpath/$item" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment