Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Git Basics Merging Basic Merging

Git auto-merge didn't happen in the console

I am following along in the Git Basic course, and the auto-merge mentioned here didn't actually happen. Instead, I got an error talking about conflicts, and also in git log it shows this:

screenshot

Any idea why this might happen?

5 Answers

Michael Hulet
Michael Hulet
47,913 Points

What you ran into is a "merge conflict". That means that the same line(s) of the same file(s) was edited multiple different ways, and git doesn't know which one to use. If you open the offending file(s) (in this case, README), you can see where git marked what's conflicting. Just delete the one you don't want, along with any text that git inserted, and then try running the merge again

Gotcha! I still wonder why the console for the course didn't operate the way it did in the video--in other words, I watched what the instructor did, and the console didn't auto-merge in the same way. *shrug*

What can you do, eh? :-)

Lindsay Terrell
Lindsay Terrell
9,888 Points

I wonder if the issue is that you made a change that was too different than what Tommy did?

Jake Wiesler
Jake Wiesler
3,124 Points

Same here. Console output was completely different than the video even though I followed the exact directions.

Alirio Lancheros
Alirio Lancheros
3,522 Points

I also had the same problem. This is what I did before merging:

  1. I created a new file called README at master in which I added two lines "Line 1" and "Line 2".
  2. Then I added README with "git add README"
  3. Then I committed README with "git commit -a -m "README from scratch".
  4. Then I created and move to other branch with "git checkout -b branch1".
  5. Then I went back to master with "git checkout master".
  6. Then I changed "Line 1" to "Line 1a".
  7. Then I had to add the README file with "git add README". This step was strange for me since I had added it before.
  8. Then I commited it with "git commit -a -m "README has been changed to Line 1a - master".
  9. Then I moved to branch1 with "git checkout branch1".
  10. Then I commited with "git commit -a -m "README has been changed to Line 2a - branch1".
  11. Then I moved to master with "git checkout master".
  12. Then I merged with "git merge branch1".

After the above I had the following message: "Auto-merging DOC CONFLICT (content): Merge conflict in DOC Automatic merge failed; fix conflicts and then commit the result"

Please help about it. What was wrong?

Julian Betancourt
Julian Betancourt
11,466 Points

For those following along, I found this: http://githowto.com/resolving_conflicts

It seems like you have to edit the file manually and then commit the change