2

I'm newbie in Github integration with eclipse. After committing my changes I have taken pull and it showing conflict in one file.

Find below details :

enter image description here

I want to neglect my changes and keep the other user changes. I am stuck at how to do this. Tried merging in following way :

enter image description here

It is showing comparison in that file but I am not able seeing the option to revert my changes and keep the other users changes

This is comparison file :

enter image description here

Can anyone help me to do this

NarendraR
  • 7,577
  • 10
  • 44
  • 82
  • Do you only feel comfortable using the merge tool, or would you be open to resolving the conflicts in the original file which is in conflict? – Tim Biegeleisen May 23 '17 at 05:32
  • I just wanted to resolve the conflict and push the changes, But i'm not getting the steps to resolve the conflict – NarendraR May 23 '17 at 05:36

1 Answers1

6

I am posting this answer to describe how to manually resolve merge conflicts in Git. This is the usual method I use, because I prefer to not have an interface sitting on top of Git when I do things. Consider one conflict in your file:

<<<<<<< HEAD
    Thread.sleep(1500);
=======
    Thread.sleep(1400);
>>>>>>>

The <<<<<<, >>>>>>>, and ======= symbols are conflict markers, and they tell you the area in the file where there is a conflict. A conflict can be thought of two different versions of the same story. In the above case, one parent in the merge wants to sleep for 1500ms, while the other wants to sleep for 1400ms. You need to decide which version is the one you want after the merge. Assuming the former, you would delete all the above 5 lines except for the line containing the actual call to Thread.sleep() which you want to retain. Hence, you would be left with this:

    Thread.sleep(1500);

Repeat this process for all conflicts. Once you are done, do a file-scoped search for ======= and the other markers. If you don't find them, and you are confident in your merging logic, then you are done. You should be able to right click the file in Eclipse and do "Add to index." This marks the file as having been resolved.

Note that you could also consider using Eclipse's merge tool. In this case, you would be presented with two different versions of the file, and you could choose from either or both versions to resolve the conflict.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • Thanks For answer. I have resolve the conflict where ever it was in file . also did that file "add to index" But while i do commit that file it is showing error "Repository State : Conflict" – NarendraR May 23 '17 at 05:55
  • Then maybe you missed a file. What does `git status` show you from the command line? – Tim Biegeleisen May 23 '17 at 05:55
  • I'm using eGit in eclipse – NarendraR May 23 '17 at 05:56
  • No, you're using Git _and_ eGit in Eclipse. Check the bash with `git status`. – Tim Biegeleisen May 23 '17 at 05:57
  • I'm not getting where to get git status – NarendraR May 23 '17 at 06:07
  • Open the Git bash (_outside_ Eclipse), type `git status` and see what it tells you. The drawback of using eGit is that you lose some fine-grain control over what is happening. For this reason, I almost always use Git directly and do not rely on them. – Tim Biegeleisen May 23 '17 at 06:08
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/144902/discussion-between-tuks-and-tim-biegeleisen). – NarendraR May 23 '17 at 06:25
  • check this https://stackoverflow.com/questions/38768660/how-can-i-get-rid-of-eclipse-git-conflict-icons-after-all-merges-are-resolved/38784095#38784095 and this https://stackoverflow.com/a/22399149/1391924 – Chandrayya G K May 23 '17 at 10:25