Reputation: 12423
I need to make a patch for someone (they are not using git) - a zip of the files changed by a commit.
I thought something like
git archive --format=zip commitguid > myfiles.zip
but this extracts the entire thing, not just the changed files. Is there any way to do this? And to make it more complicated - is there any way of doing this with multiple commits (yes I should have branched before making the changes but that's hindsight)
EDIT
Based on @Amber solution below I can do this in 2 steps in Git Bash for windows with 7Zip installed in c:\data\progs.
git diff --name-only a-sha b-sha > tmp.txt
/C/data/progs/7za.exe a myzip.zip @tmp.txt
Upvotes: 9
Views: 7426
Reputation: 175
I found this solution to the question (on github-gist, from user rmkpatchaa).
It doesn't require any external tools and is a one line command in a windows Git Bash window:
git archive --output=changes.zip HEAD $(git diff --name-only SHA1 SHA2 --diff-filter=ACMRTUXB)
It creates a standard zip archive with only the files changed between the two commits, no extra git stuff or anything, and doesn't require any extra tool on the receiving side.
Upvotes: 1
Reputation: 15644
See also git help format-patch
. It produces a diff patch of all changes in a commit along with commit author, date, message, and some nice diff stats. You could zip and send that.
Upvotes: 1
Reputation: 527328
git diff --name-only <oldsha> <newsha> | zip dest.zip -@
filling in the proper SHAs/refs. For instance, to create a zip of only the files that changed between the master
and feature
branches:
git diff --name-only master feature | zip dest.zip -@
Upvotes: 19