1

I have observed that new files get imported just fine.

But code on a new line, even if at the end of existing code/code on a line that did not exist before, is being detected as a conflict.

What is the definition of conflict ? I have read that if code is modified on the same line its a conflict, but i see conflicts if i add code in github on lines that i have kept empty in my eclipse IDE.

I have not used a command like git pull or git merge.

I am using eclipse Git plugin.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
bioki koi
  • 57
  • 6
  • 2
    See [What are the reasons and cases that cause git merge conflicts?](https://stackoverflow.com/q/44359334/1256452) – torek Feb 23 '20 at 20:08
  • ... and whatever you do, set `merge.conflictStyle` to `diff3`. – eftshift0 Feb 24 '20 at 01:27
  • Does this answer your question? [What are the reasons and cases that cause git merge conflicts?](https://stackoverflow.com/questions/44359334/what-are-the-reasons-and-cases-that-cause-git-merge-conflicts) – phd Feb 24 '20 at 10:03

2 Answers2

1

Do git diff tip1...tip2, and git diff tip2...tip1 that will show you the two sets of changes Git's merging. If overlapping or abutting change hunks in the two sets don't match, those hunks conflict.

For many, almost all ordinary histories the above description is exact. Once you start getting comfortable with merging you'll sometimes merge both directions, in those cases Git will construct a recursive merge base that gives better results than picking just one of the existing ones; and for those, the diff hunks you get from the git diffs above don't tell the whole story. But the idea's the same: changes to abutting or overlapping line ranges that don't make the same changes are judgement calls, human eyes needed. The recursive merge automates some resolutions that got tedious in heavy traffic.

jthill
  • 55,082
  • 5
  • 77
  • 137
0

If the same file is edited twice and those changes are merged together, git does not know how to do it.

This is called a merge conflict.

A merge conflict may occur if you merge 2 branches but it can also occur if somebody else pushed and you pulled that change afterwards.

EGit just executes git commands.

Therefore, a merge conflict can occur if EGit merges changes.

Eclipse shows you the conflicting files with a red , notated square next to the file icon.

When opening the file in eclipse, you will see where the conflict occurs. Git inserts both versions into the file and you should decide what you want to use.

Fix it, remove the markers, add the conflicting files and commit (and push) to resolve the conflict.

dan1st
  • 12,568
  • 8
  • 34
  • 67