Create a patch including specific files in git

后端 未结 2 1768
隐瞒了意图╮
隐瞒了意图╮ 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.

提交回复
热议问题