tags:

views:

42

answers:

2
  1. I have made a central bare shared repo at foo.org.
  2. user A has done git clone ssh://foo.org/blah.git
  3. user A has created file 'lol' which is a blank file. Commits it to local repo. Does git push
  4. user B does mkdir foo and cd foo
  5. user B then does git clone ssh://foo.org/blah.git.
  6. user B edits lol file.
  7. user A edits lol file.
  8. user A commits and git push to central repo
  9. user B commits and git push and is given:

    error: failed to push some refs to 'ssh://foo.org/blah.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. See the 'non-fast forward'

  10. user b does git pull

    From ssh://foo.org/home/meder/central/foo 08a0cda..fba6968 master -> origin/master Auto-merging lol CONFLICT (content): Merge conflict in lol Automatic merge failed; fix conflicts and then commit the result.

  11. user b does vim lol and edits file to his liking. then tries git commit afterwards and is given:

    lol: needs merge lol: unmerged (039727ec5a50d0ed45ff67e6f4c9b953bd23c17d) lol: unmerged (9307e337aa159ed6574eb84532f107685e46a16c) lol: unmerged (f88ad411f67850938dc369426cdbba76812e9126) error: Error building trees

What do I have to do at this point? I tried a git merge but it says fatal: You have not concluded your merge. (MERGE_HEAD exists)

I know for sure I'm doing something stupidly wrong. Can someone just point out what it is?

+1  A: 

In step 11, has user b done a 'git add' to add their hand-merge, before 'git commit'?

Graham Perks
`lol` exists already since it was cloned from central repo.
meder
this should be a comment, not an answer...
Climber104
hm, i actually think you're right. i didn't do an explicit `git add lol` on the hand-merge. so does git change the branch or un-add it? or did i never add it in the first place? *confused*
meder
You have to 'git add' the modification before 'git commit'. 'git commit -a' will do the add for you, too. I know it's the same command as for adding a new file; you have to do the same for merges too.
Graham Perks
A way to picture this is the think that you have to 'add' your modification/change to git.
Graham Perks
I don't understand why this should be a comment. It's the answer!
Graham Perks
@Graham: I think it's your phrasing of this as a question that got you that comment comment; requests for more information should be comments. You might want to edit it to be a statement (with an explanation). It is indeed the answer, though. (+1)
Jefromi
@meder: git does not change the branch or un-add content. It finds a conflict, and therefore does not know what content to add. It lets the user resolve the conflict (you mentioned editing the file), and then the user must tell git to add that *new* content. Yes, the content is new - git had no idea how you were going to resolve it. It would've resolved it for you if it did! So, you have to tell git: here, stage this content for commit. Same as with any other content you want git to know about.
Jefromi
A: 

Already answered here: http://stackoverflow.com/questions/161813/how-do-i-fix-merge-conflicts-in-git

Climber104
As you told Graham, this should be a comment, not an answer. (Or once you get enough rep, a close vote.)
Jefromi