-
-
Save biplobice/12151ee4de8871e75dd1df36dd185115 to your computer and use it in GitHub Desktop.
Creates an archive of all files changed in a git repository 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 | |
# Explains how to use the script | |
usage() | |
{ | |
cat << EOF | |
usage: $0 options | |
$0 -o output_file.zip commit_from [commit_to] | |
Description: | |
The script creates a zipped archive of only modified files in a git repository | |
OPTIONS: | |
-h Shows this message | |
-o Optional. Sets the output file. | |
EOF | |
} | |
# Create the variables used | |
FILENAME= | |
# Extract the arguments | |
while getopts "ho:" flag | |
do | |
case $flag in | |
h) | |
usage | |
exit 1 | |
;; | |
o) | |
FILENAME=$OPTARG | |
shift | |
;; | |
esac | |
shift | |
done | |
FROM=$1 | |
TO=$2 | |
: ${TO:="HEAD"} | |
git diff -z --name-only $FROM $TO | xargs -0 git archive $TO -o $FILENAME -- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment