单个文件的格式补丁
我有一个名为 test_module.c 的文件,它有一些差异,我想将其应用到我的本地工作副本。
我尝试通过执行以下操作从远程创建补丁文件。然而,git 并没有抱怨任何错误。并且也没有创建任何补丁文件。
git format-patch master/dev_branch test/test_module.c
是否可以创建一个我可以应用的单个文件的补丁?
(使用git版本1.7.5.4)
I have a file called test_module.c that has some differences that I want to apply to my local working copy.
I tried to create patch file from the remote by doing the following. However, git didn't complain about any errors. And didn't create any patch file either.
git format-patch master/dev_branch test/test_module.c
It is possible to create a patch of a single file, that I can apply?
(Using git version 1.7.5.4)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您给
git format-patch
一个单独的修订版,它将为自该修订版以来的每次提交生成补丁。如果您没有看到该命令的输出,那么我怀疑在origin/master
和您当前的HEAD
之间该文件没有发生任何更改。作为替代方案,您可以提供一个修订范围(例如origin/master~3..origin/master
),其中涵盖对该文件引入的更改。或者,如果您想要生成补丁的更改仅包含在origin/master
尖端的单个提交中,则可以使用-1
参数,如下所示在:If you give
git format-patch
a single revision, it will produce patches for each commit since that revision. If you see no output from that command, then I suspect that there were no changes to that file betweenorigin/master
and your currentHEAD
. As an alternative, you can provide a revision range (e.g.origin/master~3..origin/master
) which covers the changes introduced to that file. Or, if the changes you want to produce a patch for are just contained in the single commit at the tip oforigin/master
, you can use the-1
parameter, as in:您可以使用以下语法为单个文件创建补丁:
You can use following syntax for creating patch for single file: