Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging from one branch to another brings up conflicts

Tags:

git

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.

like image 757
dallen Avatar asked Dec 04 '25 18:12

dallen


1 Answers

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:

  • http://githowto.com/resolving_conflicts
  • http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging#Basic-Merge-Conflicts
like image 169
rjmackay Avatar answered Dec 06 '25 07:12

rjmackay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!