Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve conflicts while merging and updating files in git?

I feel I am approaching this all wrong.

I work as part of team and we use git. Now, when I pull updates from my team there are obviously conflicts from time to time - git seems to insert loads of text in the files which isn't good.

Anyway, is there a decent way to manage these conflicts (I'm on windows).

I used winmerge, but from what I can see, It can only compare 2 directories. It makes resolving conflicts a breeze, but requires me to have 2 states of the source in 2 different locations.

Does anybody know a better way to do this or how to integrate the two?

like image 240
Damien Roche Avatar asked Feb 02 '11 08:02

Damien Roche


1 Answers

You can define a mergetool for Git which gets launced for each conflicting file. This works fine if you only have a small number of conflicts. Some links: Using Beyond Compare, discussion about this on SO, more general instructionsand the man page.

There are some script packages that can be used if you have lots of changes.

Basically what you need to do is to get e.g. Beyond Compare to work in Linux:

git config --global merge.conflictstyle=diff3
git config --global merge.tool=bc3
git config --global mergetool.bc3.cmd=/usr/bin/bcompare $LOCAL $REMOTE $BASE $MERGED
git config --global mergetool.bc3.trustexitcode=true

You can find info on other tools easily, and Git already has support for several tools.

like image 105
Makis Avatar answered Nov 06 '22 19:11

Makis