dallen
dallen

Reputation: 2651

Merging from one branch to another brings up conflicts

I have the master (HEAD) branch and a development branch. When I'm on the dev branch and make changes, I want to basically merge those changes into HEAD.

git checkout master git merge develop

This is the error:

Auto-merging addons/shared_addons/themes/beaver/views/partials/footer.html
CONFLICT (content): Merge conflict in addons/shared_addons/themes/beaver/views/partials/footer.html
Automatic merge failed; fix conflicts and then commit the result.

So what am I doing wrong? To give you an idea of my workflow:

I have a post-commit that detects if I'm on master, then it performs a command. But if I'm on development, it won't. So while I'm in dev making changes, I basically just want to pull all changes from Dev to Master.

Upvotes: 3

Views: 1041

Answers (1)

rjmackay
rjmackay

Reputation: 144

You're not doing anything wrong, sometimes a merge will have conflicts. This usually happens when the same line in the same file has changed on both the develop and master branches.

What you need to do is resolve those conflicts and then commit the result. If you look in addons/shared_addons/themes/beaver/views/partials/footer.html you should areas with conflicts marked. Marked areas begins with <<<<<<< and ends with >>>>>>>, and the two conflicting blocks themselves are divided by =======.

For example:

<html>
  <head>
<<<<<<< HEAD
    <link type="text/css" rel="stylesheet" media="all" href="style.css" />
=======
    <!-- no style -->
>>>>>>> master
  </head>
  <body>
    <h1>Hello,World! Life is great!</h1>
  </body>
</html>

Resolve the conflict manually

<html>
  <head>
    <link type="text/css" rel="stylesheet" media="all" href="style.css" />
  </head>
  <body>
    <h1>Hello,World! Life is great!</h1>
  </body>
</html>

Then add the file and commit the merge

git add addons/shared_addons/themes/beaver/views/partials/footer.html
git commit -m "Merged develop into master fixed conflict."

These page have more detailed guides about resolving merge conflicts:

Upvotes: 5

Related Questions