Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extract all files changed in a git commit

Tags:

git

windows

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
like image 812
Andiih Avatar asked May 29 '12 17:05

Andiih


People also ask

How do you see all files changed in a commit?

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.

How can I see which files have been changed in a branch?

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...

What is the git command to view all the changes since last commit?

By default git diff will show you any uncommitted changes since the last commit.


2 Answers

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 -@
like image 157
Amber Avatar answered Sep 29 '22 13:09

Amber


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.

like image 40
ulidtko Avatar answered Sep 29 '22 11:09

ulidtko