4

Suppose I merge a branch to the master. Since I do not want to merge everything I run git merge --no-commit, check merged files manually, and decide to exclude some of them from the merge. So, I run git reset HEAD <file> and git checkout <file> for every file I want to exclude from the merge.

Does it make sense? Is there a better way to do it?

Michael
  • 10,185
  • 12
  • 59
  • 110

3 Answers3

3

That should work. You can also checkout each file from the version where you were:

git checkout HEAD -- <a list of the files you want to not change>

Why, may I ask, do you need to do this?

Hope this helps

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
1

Note that it can also work for directories, as in this thread:

git checkout HEAD -- top/middle/mydirectory  

would restore all the files within 'mydirectory'

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

There is no need to execute git reset HEAD <file> before git checkout <file>. The single git checkout <file> will do the same.

the.malkolm
  • 2,391
  • 16
  • 16