Favor everything on HEAD in a Git merge conflict
Public, Git
harrylevine
Created: Sep 28, 2017 Updated: Sep 28, 2017
Let's say that you are rebasing your current branch on master
, and you run into merge conflicts. For example with a blog.rb
file. If you have a situation where you might be inclined to fix it by:
master
blog.rb
fileblog.rb
file with the one from master
A quicker way to achieve that would be to use either of these commands:
The .
replaces all files that are currently not committed, with the ones from head
/master
Replaces just the specified file with the one from head
/master
i.e. git checkout --ours app/models/blog.rb
On the flip side, you may want to favor your current branch, over the one you are rebasing on (master
in this case). This --theirs
flag would accomplish that.