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 manuall开发者_开发技巧y, 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?
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
There is no need to execute git reset HEAD <file>
before git checkout <file>
. The single git checkout <file>
will do the same.
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
'
精彩评论