1

I'm on Chapter 5 of Michael Hartl's "Ruby Tutorial". I tried to merge branches, was on the wrong branch and took myself down the rabbit hole. I've got pretty far out of the way after doing some backtracking but now this is my issue again.

****Captains-iMac:sample_app owner$ git pull origin master
U   app/views/layouts/application.html.erb
U   app/views/static_pages/home.html.erb
U   config/routes.rb
U   test/controllers/static_pages_controller_test.rb
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution and make a commit.****

The master branch is the one that is currently correct for me. Any pointers for a complete newbie?

Barett
  • 5,826
  • 6
  • 51
  • 55
duwerq
  • 99
  • 9
  • I think you have to manually merge the files to avoid conflicts. – Pavan Jul 17 '15 at 16:26
  • There are several ways of solving your problem. Question is do you care about your local changes? or you do not mind to discard them. Show your `git status` output – Tim Jul 17 '15 at 16:44
  • On branch master Your branch and 'origin/master' have diverged, and have 4 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) You have unmerged paths. (fix conflicts and run "git commit") Unmerged paths: (use "git add ..." to mark resolution) both modified: app/views/layouts/application.html.erb both added: app/views/static_pages/home.html.erb both modified: config/routes.rb both added: test/controllers/static_pages_controller_test.rb no changes added to commit (use "git add" and/or "git commit -a") – duwerq Jul 17 '15 at 21:07

2 Answers2

3

One thing you could do is to use git checkout <file> to check out the committed version of the file (thus discarding your changes), or git reset --hard HEAD to throw away any uncommitted changes for all files.

WARNING: The latter will discard all of your local changes. Do this only if you do not particularly care about changes that you made locally.

Otherwise, I encourage you to check out this excellent post, where the author of the accepted answer goes in depth about the sort of problem you are experiencing right now.

Hope this helps you out.

Community
  • 1
  • 1
Tim
  • 1,326
  • 1
  • 15
  • 27
  • +1 for the post cited by @Tim Kos. It looks like exactly the same error on roughly the same place in the tut. – Mauddev Jul 17 '15 at 18:50
  • Thanks Tim for making helping me through my first post on here, I really appreciate it. – duwerq Jul 17 '15 at 21:08
1

These were the files that were conflicting:

git pull origin master
U   app/views/layouts/application.html.erb
U   app/views/static_pages/home.html.erb
U   config/routes.rb
U   test/controllers/static_pages_controller_test.rb
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution and make a commit.

Here was exactly what I typed to fix it:

Captains-iMac:sample_app owner$ git add app/views/layouts/application.html.erb Captains-iMac:sample_app owner$ git add app/views/static_pages/home.html.erb Captains-iMac:sample_app owner$ git add config/routes.rb Captains-iMac:sample_app owner$ git add test/controllers/static_pages_controller_test.rb Captains-iMac:sample_app owner$ git commit -m "resolved merge conflicts" [master 891a992] resolved merge conflicts

duwerq
  • 99
  • 9