Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge conflict Git

Tags:

git

egit

I and my friend fork from the main repository (upstream). Last night, we had the same version of this repository in local machine. Then I have added a new feature and my friend also added another new feature too. My friend pulled request to the main repository and I have merge this pull request with the upstream repository with no conflict. And when I fetch from upstream and merge with my master branch, it conflicts. What should I do in this situation to resolve conflict? (The upstream repository should have 2 new features after resolving conflict)

like image 771
Duc Le Avatar asked Apr 29 '12 04:04

Duc Le


3 Answers

Note that you can also solve directly a merge conflict from Eclipse/Egit itself:
See "Egit: Solving Merge Conflicts":

You can manually edit the text on the left side or use the Copy current change from right to left button to copy the conflicting changes from right to left.

Next step is from the context menu of the file, to select Team -> Add to index. Than commit.

merge conflict resolution in EGit

like image 58
VonC Avatar answered Oct 23 '22 00:10

VonC


Just go through the files marked as conflicted by git status and find the conflict markers (you can search for ==== in the file). Reconcile the changes between them, figure out if anything else unexpected got broken by the combination of your code, run your tests, and then use git add and git commit as normal to make a commit merging your friend's new feature with yours.

Upstream: original                 with friend's feature            with both
               \  \               /                \               /
                \  -- Friend's --/                  \             /
                 \                                   \           /
                  ---- Yours ------------------------- your merge
like image 21
Danica Avatar answered Oct 22 '22 23:10

Danica


You can type git difftool path/filename in the console to use a tool to resolve the conflict or use Git software that has conflict resolution built in. I really like SmartGit (from the makers of SmartSVN) and TortoiseGit (very similar to TortoiseSVN).

like image 1
xeorem Avatar answered Oct 23 '22 00:10

xeorem