Skip to content

Instantly share code, notes, and snippets.

@kaminaly
Last active November 22, 2018 03:55
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kaminaly/5670536 to your computer and use it in GitHub Desktop.
Save kaminaly/5670536 to your computer and use it in GitHub Desktop.
gitで差分ファイルを抽出する ref: http://qiita.com/kaminaly/items/28f9cb4e680deb700833
git archive --format=zip --prefix=root/ HEAD `git diff --diff-filter=d --name-only HEAD^ HEAD` -o archive.zip
function git_diff_archive()
{
local diff=""
local h="HEAD"
if [ $# -eq 1 ]; then
if expr "$1" : '[0-9]*$' > /dev/null ; then
diff="HEAD~${1} HEAD"
else
diff="${1} HEAD"
fi
elif [ $# -eq 2 ]; then
diff="${2} ${1}"
h=$1
fi
if [ "$diff" != "" ]; then
diff="git diff --diff-filter=d --name-only ${diff}"
fi
git archive --format=zip --prefix=root/ $h `eval $diff` -o archive.zip
}
git_diff_archive
git_diff_archive 数値
git_diff_archive コミット識別子
git_diff_archive コミット識別子1 コミット識別子2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment