简体   繁体   English

提取git提交中更改的所有文件

[英]extract all files changed in a git commit

I need to make a patch for someone (they are not using git) - a zip of the files changed by a commit. 我需要为某人制作补丁(他们不使用git) - 通过提交更改的文件的zip。

I thought something like 我觉得有点像

git archive --format=zip commitguid > myfiles.zip 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. 基于下面的@Amber解决方案,我可以在Git Bash的两个步骤中执行此操作,在Windows中安装了7Zip的c:\\ data \\ progs。

git diff --name-only a-sha b-sha > tmp.txt
/C/data/progs/7za.exe a myzip.zip @tmp.txt
git diff --name-only <oldsha> <newsha> | zip dest.zip -@

filling in the proper SHAs/refs. 填写适当的SHAs / refs。 For instance, to create a zip of only the files that changed between the master and feature branches: 例如,要创建仅包含master分支和feature分支之间更改的文件的zip:

git diff --name-only master feature | zip dest.zip -@

See also git help format-patch . 另请参阅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. 它生成一个提交中所有更改的diff补丁,以及提交作者,日期,消息和一些不错的差异统计信息。 You could zip and send that. 你可以压缩并发送它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM