Merging Git Conflicts On Github

This article applies to following environments (but conceptually it can be applied to any environment):

  • Github
  • Windows 7

If you’ve been relying on the github GUI, you may get (very) annoyed when the conflict screen appear (Failed to sync this branch due to unmerged files)

gitmerge

This is few (often not so) simple steps to resolve the conflicts:

  1. Click OPEN SHELL, a windows powershell will come up
  2. Start by running git status, this command will help you as you progress resolving the conflict. It also contain pretty clear instruction on how to mark a file resolved, and how to finish conflict resolution
  3. In this examply (luckily) I only have 1 file in conflict hello.txt. Open it using a text editor, and edit the conflict. Conflicts are presented in a unified diff format:
    hello world
    <<<<<<< HEAD
    mary
    =======
    bobby
    >>>>>>> bobby
    the many
    testing
    file
    

    Above example is saying you changed the 2nd line to “mary”, but your colleague changed it to “bobby”. You now have to decide either (or merge both).

  4. For every conflict you resolved, you can tell git so by git add command, eg: git add hello.txt
  5. Once all conflicts are resolved do git rebase –continue command (if you’re in rebase mode — sometime github will use other conflict resolution and will tell you what command to run when completed)
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s