Last active
August 29, 2015 14:11
-
-
Save tkdn/349edbb1e570799eb196 to your computer and use it in GitHub Desktop.
gitで差分ファイルを抽出する(改変) ref: http://qiita.com/tkdn/items/d6980079b950b584a070
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
function git_diff_archive() | |
{ | |
dateTime=`date '+%Y%m%d%H%M'` | |
local diff="" | |
local h="HEAD" | |
if [ $# -eq 1 ]; then | |
if expr "$1" : '[0-9]*' > /dev/null ; then | |
diff="HEAD HEAD~${1}" | |
else | |
diff="HEAD ${1}" | |
fi | |
elif [ $# -eq 2 ]; then | |
diff="${1} ${2}" | |
h=$1 | |
fi | |
if [ "$diff" != "" ]; then | |
diff="git diff --name-only ${diff}" | |
fi | |
git archive --format=zip $h `eval $diff` -o ${PWD##*/}-$dateTime.zip | |
} | |
alias git_diff_archive=git_diff_archive |
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
$ git_diff_archive ab8c41c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment