How to resolve Git merge conflict

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

  • How to create a selective pull-request with Github - hg-Git - Mercurial?
  • Exclude specific files when pushing to a specific Git repository
  • Are file permissions and owner:group properties included in git commits?
  • How to checkout a remote branch in Git?
  • Finding next matching hunk when using git add --patch
  • Auto commit on file modify with SVN (or git)?
  • enter image description here

    How do I fix it?

  • Gitflow with Github setup
  • Change Git commiter in Netbeans
  • How do I change files in a specific Commit in my history?
  • How to recover lost commit with git?
  • Git and Dos - how to exit a command
  • Bash scripting, git and filenames with spaces
  • 3 Solutions collect form web for “How to resolve Git merge conflict”

    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
    

    I typically use git mergetool to resolve conflicts.

    It launches the predefined visual merge tool.

    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!

    Git Baby is a git and github fan, let's start git clone.