Create a patch including specific files in git

后端 未结 2 1754
隐瞒了意图╮
隐瞒了意图╮ 2020-12-28 13:03

Let\'s say that I am 7 commits ahead of the origin/master repo. I would like to create a patch that includes in the patch specific files that were changed, not all the files

相关标签:
2条回答
  • 2020-12-28 13:37

    You can restrict the output of git diff by listing paths at the end of the command (after a -- to avoid any potential clashes between path names and branch names). For example, you could do the following:

    git diff origin/master HEAD -- app/models/region.rb doc/ > changes.patch
    

    ... to generate a patch that only shows the differences within a particular file and a particular directory.

    0 讨论(0)
  • 2020-12-28 13:50

    You can include files in the patches with:

    git format-patch <rev> <files...>
    

    Example

    git format-patch HEAD^^^ Makefile
    

    Will give you three files 0001-[commit] ... 0003-[commit] only containing the Makefile.

    0 讨论(0)
提交回复
热议问题