Reputation: 12954
With Git I am on a branch. I am rebasing the branch atop master. There is a conflict that I want to resolve by ignoring the branch's version and accepting master's version. How do I indicate I want to use master's version of the file during the rebase?
Upvotes: 12
Views: 14675
Reputation: 20148
git checkout --ours <path-to-file>
is the command you are looking for.
It will checkout the master version of the file which you then can add to the index (to mark the conflict resolved) and continue your rebase.
You can take a look at the checkout documentation for more information.
See the comment under --merge
as to why you need to use --ours
and not --theirs
.
Upvotes: 17
Reputation: 778
Just in case anyone stucks as myself.
If you want to override all your local changes with "theirs", it is probably because someone removed a commit your local branch was referred to and added a new one and you're doing a rebase, so that git tries to apply (this old commit + yours) on top of theirs.
In this case use git rebase -i remote-branch
and comment out the old commit.
Hope this helps.
Upvotes: 1
Reputation: 1960
If you want keep current branch file use git checkout --ours filenamewithpath
If you want to keep other branch file use git checkout --theirs filenamewithpath
Please check this link http://gitready.com/advanced/2009/02/25/keep-either-file-in-merge-conflicts.html
Upvotes: 3