3

I am new with github and am trying to merge my master and gh-pages branches.

While trying to merge, I had a conflict. Now I get the following message

enter image description here

How do I fix it?

Lazy Badger
  • 87,730
  • 7
  • 72
  • 97
ptamzz
  • 8,567
  • 30
  • 87
  • 138
  • [git-mergetool](http://linux.die.net/man/1/git-mergetool) – Lazy Badger Mar 05 '12 at 22:00
  • possible duplicate of [How do I fix merge conflicts in Git?](http://stackoverflow.com/questions/161813/how-do-i-fix-merge-conflicts-in-git) –  Apr 16 '14 at 23:10

3 Answers3

7

I typically use git mergetool to resolve conflicts.

It launches the predefined visual merge tool.

Olivier Refalo
  • 46,213
  • 20
  • 84
  • 114
5

Take a look at your current status:

git status

You'll probably see some files which are staged for commit and some which have local changes. The staged ones are those which merged without problem. The ones with local changes have merge conflicts. Open up each of those files, and you'll see something like this somewhere inside:

<<<<< master
// some code that was in master
=====
// some code that was in gh-pages
>>>>> gh-pages

(I think it's something like that anyway)

Edit each of them so they are how you want them to be (ie: fix the conflicts). Then do as it says:

git add the/file/i/fixed.txt
git commit
nickf
  • 499,078
  • 194
  • 614
  • 709
0

Basically, try following steps as rule of thumb


Look at current status

git status

If you do not have anything which is not tracked or not committed, you'll something like following enter image description here

At this point you will have to commit the files


Add to track and commit

git add-commit -m 'commit message'

At this point you will have: Commited

You can now merge a branch into current branch or checkout some other branch via

git checkout <branch>

and merge some branch


Merge a branch

git merge <branch>

Make sure you have no conflicts and you can successfully merge a branch now.

If you in case have merge conflicts, you will see something like:

Conflicts

You now need to decide on what changes you need to keep to the conflict file, <<<<<<<<<< HEAD indicates that the change was in parent branch whereas >>>>>>>>>>> refs/heads/new_idea is what actually was added from the branch you are trying to merge.

You can utilize various merge tools to look at and solve conflicts, for assistance on merge tool have a look at git mergetool

Hope it helps!

Darshan Lila
  • 5,216
  • 2
  • 21
  • 34