简体   繁体   English

Git创建完整的文件补丁下载/分发?

[英]Git create full file patches to download/distribute?

Either i'm going nuts or nobody likes/liked this feature, but a long time ago i used to use subversion with sourceforge system. 无论是我疯了还是没有人喜欢/喜欢这个功能,但很久以前我曾经使用过sourceforge系统的subversion。 I had the ability to create full file patches for commits done. 我有能力为提交的提交创建完整的文件补丁。

I cannot figure out anyway to create these in git, all i want is the files that were changed from XX commit and only those files in their entirety so that i could hand them off to someone/upload just those files to a location. 无论如何我无法弄清楚在git中创建这些,我想要的只是从XX提交更改的文件,只有完整的文件,以便我可以将它们交给某人/只将这些文件上传到某个位置。

As it currently stands i'm stuck reuploading the entire project because i have nothing that tells me what was changed. 因为它目前正在重新上载整个项目,因为我什么都没有告诉我改变了什么。 Since we're also on a shared web host there is no way to get git on the server without upgrading to more expensive package. 由于我们也在共享的Web主机上,因此无需升级到更昂贵的软件包就无法在服务器上获取git。

I've tried 我试过了

git archive --output=/home/username/temp.zip <commit id>

which put everything into a zip nicely but it did just that, it put everything. 把所有东西都放进了一个拉链很好但是就是这样,它把所有东西都放了。 Also tried a variation of format-patch but that didn't seem to work. 还尝试了格式补丁的变体,但似乎没有用。

It seems that I misunderstood what you wanted in my other answer. 在我的另一个答案中,我似乎误解了你想要的东西。 git archive can take a list of paths to include in the archive, so you could do: git archive可以列出要包含在存档中的路径,因此您可以执行以下操作:

git archive -o /tmp/foo.zip HEAD $(git diff --name-only oldcommit HEAD)

If your filenames contain surprising characters, though, it would be safer to do: 但是,如果您的文件名包含令人惊讶的字符,那么它会更安全:

git diff -z --name-only oldcommit HEAD | xargs -0 git archive HEAD -o /tmp/blah.zip --

The first thing to try would be to save the output of git diff , which might be sufficient in your situation: 首先要尝试的是保存git diff的输出,这在你的情况下可能就足够了:

git diff oldcommit > test.patch

If you have changed binary files since then, you could try: 如果您从那时起更改了二进制文件,您可以尝试:

git diff --binary oldcommit > test-with-binaries.patch

In that case you'd then need to apply the patch with git apply . 在那种情况下,您需要使用git apply来应用补丁。 Otherwise, I would create a new branch based on oldcommit , do a squashed merge from master , commit the result and and use git format-patch to produce the patch. 否则,我将基于oldcommit创建一个新分支,从master执行压缩合并,提交结果并使用git format-patch生成补丁。 That method (and several other solutions to your problem) are described in more detail in the answers to this similar stackoverflow question: How do you squash commits into one patch with git format-patch? 在这个类似的stackoverflow问题的答案中更详细地描述了该方法(以及针对您的问题的其他几种解决方案): 如何使用git format-patch将提交压缩到一个补丁中?

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

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