format-patch for a single file

后端 未结 2 1210
深忆病人
深忆病人 2020-12-15 15:31

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

相关标签:
2条回答
  • 2020-12-15 15:57

    You can use following syntax for creating patch for single file:

    git format-patch [commit_hash] [file]
    
    0 讨论(0)
  • 2020-12-15 16:13

    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
    
    0 讨论(0)
提交回复
热议问题