0

Can anybody please explain what is the best to resolve conflicts in Git. I am currently using Tortoise Git as well as SourceTree. With TortoiseGit, after getting a conflict, we get the option to "resolve conflict using theirs" or "resolve conflict using mine" in both ways it is not working. What is the best practice?

eatSleepCode
  • 4,427
  • 7
  • 44
  • 93

2 Answers2

2

In most cases, neither of these options is what you want. In most cases, you'll need to go to each conflicting code and manually merge the changes. git marks these conflicting code which you can look for then easily.

Automatic conflict resolution with theirs and mine only work for very limited situations.

Lie Ryan
  • 62,238
  • 13
  • 100
  • 144
  • To add to this, look through the code for `<<<<<<<`, `=======`, and `>>>>>>>`. These sections will mark conflicted sections of code. Manually resolve each of these sections, `add` and `commit`. See [Pro Git](http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging#Basic-Merge-Conflicts) for details. – ChrisGPT was on strike Dec 24 '13 at 13:09
  • 1
    git diff, git status, and most git GUI should also show the files and/or parts marked for merging. – Lie Ryan Dec 24 '13 at 13:26
2

Resolving conflicts manually, by editing the file to remove the <<<<<<< HEAD, =======, and >>>>>>> markers is one way but I would not consider it the best way.

Recommend using a free GUI such as:

To set a default mergetool in git, set the following global git config variables, where "toolname" is the merge tool you have installed:

git config --global merge.tool "toolname"
git config --global mergetool.toolname.path "\path\to\toolname"

Refer also to:

https://developer.atlassian.com/blog/2015/12/tips-tools-to-solve-git-conflicts/

What's the best visual merge tool for Git?

What's a good (free) visual merge tool for Git? (on windows)

TT--
  • 2,956
  • 1
  • 27
  • 46