3

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?

Elad Benda
  • 35,076
  • 87
  • 265
  • 471

1 Answers1

3

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(!).

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I want to return a specific file to version before the merge. How do i do this? – Elad Benda Aug 05 '13 at 10:53
  • @EladBenda `git checkout --ours -- afile` (if this is during a `git merge` or `git pull`, meaning you are still in the conflict resolution step: your `git pull` isn't finished yet: you are still resolving conflict, but, for that file, you want to preserve the local version) – VonC Aug 05 '13 at 11:05