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
To find out which files changed in a given commit, use the git log --raw command. It's the fastest and simplest way to get insight into which files a commit affects.
To get the list of files modified (and committed!) in the current branch you can use the shortest console command using standard git: git diff --name-only master... If your local "master" branch is outdated (behind the remote), add a remote name (assuming it is "origin"): git diff --name-only origin/master...
By default git diff will show you any uncommitted changes since the last commit.
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 -@
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With