Skip to content

Instantly share code, notes, and snippets.

@tkdn
Last active August 29, 2015 14:11
Show Gist options
  • Save tkdn/349edbb1e570799eb196 to your computer and use it in GitHub Desktop.
Save tkdn/349edbb1e570799eb196 to your computer and use it in GitHub Desktop.
gitで差分ファイルを抽出する(改変) ref: http://qiita.com/tkdn/items/d6980079b950b584a070
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
$ git_diff_archive ab8c41c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment