Skip to content

Instantly share code, notes, and snippets.

@partynight12th
Forked from func09/git-diff-zip.sh
Created October 22, 2012 05:44
Show Gist options
  • Save partynight12th/3929893 to your computer and use it in GitHub Desktop.
Save partynight12th/3929893 to your computer and use it in GitHub Desktop.
Gitで特定のコミットからの差分ファイルだけ抜き出してZipにする
#!/bin/bash
if [ $# -ne 3 ]; then
echo "Usage: git diff-zip <archive_name> <oldCommit> <newCommit>"
exit 1
fi
git archive --format=zip --prefix=$1/ $3 `git diff --name-only $2 $3` -o ../$1.zip
@partynight12th
Copy link
Author

example:
$ git diff-zip archive HEAD^ HEAD
-> create "../archive.zip" file.
-> adding "../archive.zip/archive/"
-> added file is git diff --name-only HEAD^ HEAD

@partynight12th
Copy link
Author

-> added files are

@kkotaro0111
Copy link

Install to /usr/local/Cellar/git/2.1.1/libexec/git-core/

@kkotaro0111
Copy link

git archive --format=zip --prefix=$1/ $3 `git diff --diff-filter=ARM --name-only $2 $3` -o ../$1.zip

削除ファイルも表示されてしまい、エラーが起きるので、上記に変更

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment