Checkout conflict with files. How do I proceed?
Asked Answered
T

5

7

I just pulled some changes from a remote repository holding my teams project.

This is the message I received on pull:

Checkout Conflict

Apparently, one of my partners made changed to the same file as me.

How do I proceed from here? The message is very vague. Was there an error? Do I have to undo what I did? Does he have to?

Tamra answered 9/9, 2014 at 5:32 Comment(2)
Conflict occurs when your changes cannot be merged with what is coming in because the changes are essentially on the same line. You have two options either to revert your change or manually merge the changes and commit it later.Fribble
wiki.eclipse.org/EGit/User_Guide : have a look at section 'Resolving a merge conflict'Malocclusion
W
11

I faced this issue today and below solution works for me.

  1. Do a git stash. This will consolidate all your local and conflicting changes.
  2. Do a git pull now
Wystand answered 6/4, 2016 at 11:2 Comment(1)
You resolved your conflict by effectively throwing away your changes and accepting the remote changes instead.Kristlekristo
O
2

You must manually resolve the conflict by incorporating your partner's change into your code and committing the manually merged file.

Alternatively, if your changes aren't too complex, you may revert (throw away) your changes to that file, update your code to pick up your partner's changes, and then redo your work.

See http://wiki.eclipse.org/EGit/User_Guide#Manual_conflict_resolution

Octogenarian answered 9/9, 2014 at 13:4 Comment(2)
Doing merge manually sounds right, but the EGit doc states the conflicted file should have ">>>>", "=====" and "<<<<" markers in it showing where the merge failed. I have hit this dialog when pulling, a single file is in conflict, but I find no such markers in the file. Same problem or something slightly different?Decline
That is puzzling. Perhaps the conflict is due to different end-of-line markers, or character encodings? I'm guessing wildly here. All I can recommend is that you get the two copies (yours and the version in the repository) and go through them both line by line to see what the differences are.Kristlekristo
D
2

Do you have uncommitted changes in the file that's in your working copy? Or is your working copy clean? The EGit documentation guides you thru the latter scenario.

In my experience, the error dialog posted by @lmray is what EGit shows when a local working copy has uncommitted changes. EGit wishes to merge in information from the remote but I'm told it will not modify a dirty working copy. To proceed, you must first commit your changes locally, giving you a fallback point, then request merge again. The merge should then produce a merged file, hopefully without any conflicts.

Thanks to @B. Dalton for trying to straighten me out - my dirty working copy file had uncommitted changes, and a local git wizard explained things.

Digression: this is a mental adjustment if you (like me) were used to working with SVN, which would happily pull remote changes into a dirty local working file. Not saying that was better, just that git works differently. I'm still struggling to convert my SVN-trained intuition over to suitable expectations for Git.

Decline answered 29/6, 2015 at 12:11 Comment(1)
Thanks for helping to diagnose what was, in my case, a horribly undescriptive error message! I looked at my changes and found that a file had been added when I published my app, which resulted in an uncommitted change and so I couldn't switch to the new branch I just created.Derby
T
0

In Eclipse :-

  1. Right click -> click on 'add to index'

Add conflict file in staged area

  1. Right Click ->click on commit

Add conflict file in local repository

  1. Pull

You will get all changes (change in remote repository and local repository)

Changes mentioned as Head(<<<<<< HEAD) is your change, Changes mentioned in branch(>>>>>>> branch) is other person change, you can update file accordingly.

  1. Right click ->click on add to index

  2. Right click -> commit and push

Triboluminescent answered 20/7, 2020 at 11:47 Comment(0)
S
0

Follow this steps,

  • Step1:
    • If you are using Windows OS, Use gitbash tool .
    • If you are using MAC OS, use terminal.
  • Step2: Go to your git project location using #cd <patch_of_project>
  • Step3: #git stash
  • Step4: #git pull
  • Step5: #git stash apply
  • Step6 : resolve conflict manually by this , Changes mentioned as Head(<<<<<< HEAD) is your change, Changes mentioned in branch(>>>>>>> branch) is other person change, you can update file accordingly.
Supersede answered 25/7, 2023 at 12:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.