2

I have a few commits with several files in my local repository (not pushed yet). When I am doing a git pull in (EGit) it is showing many incoming changes and one file in conflict. I just want to replace this file with incoming changes but do not want other changes in my commits to be replaced. Just a single conflicting file replace. I tried git checkout --theirs filename from git bash followed by git pull resulting in the following message- Automatic merge failed; fix conflicts and then commit the result which is clear but I want to overwrite that conflict with latest one. How can I resolve this?

I don't know is this can be done without a rebase. A similar situation is described here but that involves a rebase, which I want to avoid.

Community
  • 1
  • 1
User2709
  • 533
  • 4
  • 16
  • Possible duplicate of http://stackoverflow.com/questions/8146289/how-to-get-their-changes-in-the-middle-of-conflicting-git-rebase – Erick G. Hagstrom Mar 03 '16 at 07:27
  • I don't want to do a rebase actually, the only thing I want is to replace the conflict from the latest version in the master. So I don't think it is a duplicate. – User2709 Mar 03 '16 at 07:34

1 Answers1

2

I tried git checkout --theirs filename from git bash followed by git pull resulting in the following message- Automatic merge failed; fix conflicts and then commit the result which is clear but I want to overwrite that conflict with latest one. How can I resolve this?

You should do this:

  1. git checkout --theirs filename # you get theirs changes
  2. git add filename # add this file to stage
  3. git commit -m 'resolve conflicts during merging, get theirs' # commit changes
  4. git push # push your branch
alexander.polomodov
  • 4,849
  • 14
  • 35
  • 42
  • 1
    Thanks, but unfortunately that doesn't work for me. The moment I commit it, a pull request doesn't fetch the latest changes for some reason, maybe I am missing some git concepts here. – User2709 Mar 03 '16 at 12:06