Elad Benda
Elad Benda

Reputation: 36654

how to abort merge of a specific file using git?

I'm using git.

I have done pull action. and there was a merge conflict.

I want to return a specific file to version before the merge.

How do i do this?

After I have done this I want to pull this file only.

There will be a merge conflict. How do I:

a) take the remote version as conflict resolution?

b) take the local version as the conflict resolution?

Upvotes: 3

Views: 2906

Answers (1)

VonC
VonC

Reputation: 1324278

You can keep the version you want:

git checkout --ours -- afile
git checkout --theirs -- afile

See the gitready article "keep either file in merge conflicts ".

Make sure to read "Why is the meaning of “ours” and “theirs” reversed with git rebase", because if your merge conflict occurs during a git rebase...
then keeping your local version would be git checkout --theirs -- afile(!).

Upvotes: 3

Related Questions