格式补丁为单个文件 [英] format-patch for a single file
问题描述
我有一个名为test_module.c的文件,它有一些差异,我想将它应用到本地工作副本中。
I have a file called test_module.c that has some differences that I want to apply to my local working copy.
我尝试从远程创建补丁文件通过以下操作。但是,git并没有抱怨任何错误。
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?
(使用git版本1.7.5.4)
(Using git version 1.7.5.4)
推荐答案
如果您给 git format-patch
一个版本,它会为每个提交产生修补。如果您看不到该命令的输出,那么我怀疑 origin / master
和您当前的 HEAD $之间没有对该文件的更改C $ C>。或者,您可以提供一个修订范围(例如
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 between origin/master
and your current HEAD
. 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 of origin/master
, you can use the -1
parameter, as in:
git format-patch -1 origin/master test/test_module.c
这篇关于格式补丁为单个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!