Larry vs. the Git Rebase Merge Conflict

Posted by Larry Karnowski Tue, 10 Jun 2008 12:30:00 GMT

While doing a "git svn rebase", if you have merge conflicts here are some things to remember:

  • While doing a rebase, if anything bad happens, you end up on a "(no-branch)" branch.
  • When doing a "git status", you'll see a ".dotest" file in your working directory. Just ignore it.
  • If you want to bail, do a "git rebase --abort". (Note there is no "git svn rebase --abort".)
  • Fix the merge conflict file manually, then do a "git add [file]".
  • Next do a "git rebase --continue". (Note there's no "svn" version of this either.)
  • If it complains about "did you forget to call 'git add'?", then evidently your edit turned the conflict into a no-op change. Do a "git rebase --skip" to skip it. (Very weird, but true.)
  • Rinse and repeat until the lather is gone, your scalp silky smooth, and the rebase is complete. At any time you can "git rebase --abort" to bail.

What happened to me? Well, I didn't realize what was going on, continued to work on the "not a branch" branch, commited changes, even dcommited changes back to Subversion. It was ugly, but not insurmountable. A buddy clued me into the "not a branch" situation, I was able to get back to my real branch and resurrect my code. It took a few "git rebase --continue" commands, and a tense moment around a "git rebase --skip", but now everything's hunky dory.

This very odd email really helped me a lot. You might be interested at some point.

Tags  | 36 comments

Comments

  1. Otto said about 3 hours later:

    I think I ran into the add thing. Now I know what happened.

    It wasn't a git-svn rebase, but a git rebase master on one of my branches. I still don't understand how that particular change created conflicts. Except maybe in my TextMate project.

  2. larry said about 13 hours later:

    Otto, yeah, rebase is pretty much the same for git-svn or plain git. The things I mentioned above apply in both cases.

  3. Otto said 11 days later:

    Here's what I discovered, there's another way to get that "did you forget to call 'git add'?" message.

    I had deleted some files in both master and the branch, so git rebase master left me in a this state with a list of deleted files as un-added.

    I had to git rm the path, even though they no longer existed, then git-rebase --continue.

  4. Charles Miller said 3 months later:

    Thanks for writing this up. Very helpful.

  5. Derek Morrison said 9 months later:

    I second Charles! Thanks for writing this. Got me out of a tough and confusing spot.

  6. Graeme Geldenhuys said about 1 year later:

    I hit the same problem yesterday. Got major conflicts in a rebase. Luckily I knew I was in a strange "no-branch" situation due to my command prompt always telling me what branch I am in. I'm using Linux and added the following in my ~/.bashrc file

    # Put Git branch name it shell prompt
    parse_git_branch() {
      git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* (.*)/(\1)/'
    }
    PS1="\W\$(parse_git_branch) $ "
    

    My command prompt now always shows the branch in brackets. Like so:

     lazarus(master) $
    

    So if anybody is using Linux and Git, this should be pretty handy to you as well.

  7. cheap auto insurance said about 1 year later:

    I second Charles! Thanks for writing this. Got me out of a tough and confusing spot.

  8. Tokidoki Handbags said about 1 year later:

    I'm really impressed by your findings here. I'm looking forward to reading more of your writing.

  9. Billy said about 1 year later:

    Thanks for writing this up. Very helpful. I second Charles! Got me out of a tough and confusing best car insurance spot.

  10. ucvhost said about 1 year later:

    thanks

  11. ucvhost said about 1 year later:

    great post

  12. Fred said about 1 year later:

    Thanks! I needed that.

  13. WOW CD KEY said about 1 year later:

    just do it

  14. Che said about 1 year later:

    Thank you very much Larry, I had this unsolving merge problem since two days. Now it works with your help :-)

  15. computer science degree said about 1 year later:

    so git rebase master left me in a this state with a list of deleted files as un-added.

  16. Online Information Technology degree said about 1 year later:

    Thanks for sharing. i really appreciate it that you shared with us such a informative post..

  17. Multimedia degree said about 1 year later:

    The difference between the right word and the almost right word is really a large matter — it's the difference between a lightning bug and the lightning.

  18. Network degree said about 1 year later:

    I'm the same way, I do my best to remain neutral. It's hard, if you communicate with the person the other person dislikes, then you fall out of favor with them! I simple can't dislike a person, just because someone else does, I just can't.

  19. Online Software Engineering degree said about 1 year later:

    I will forward this article to him. Pretty sure he will have a good read. Thanks for sharing!

  20. watches uk said about 1 year later:

    Thanks for sharing. i really appreciate it that..

  21. life insurance quotes said about 1 year later:

    I second Charles! Thanks for writing this. Got me out of a tough and confusing spot.

  22. treatment for acne scars said about 1 year later:

    thank you for sharing.

  23. global education forum said about 1 year later:
    * Austria - A italian(non austrian) restaurant serving delicious dishes between 100CK and 400CK with most being around 150CK(Sept, 2006). In Prague 5, on the corner of V Botanice and Stefanikova.
    
  24. global education support said about 1 year later:

    I find your blog very informative since i can find answers to all my questions. thanks..good work..

  25. education support forum said about 1 year later:

    Thanks for taking the time to discuss this,would you mind updating your blog with more information? It is extremely helpful for me.

  26. Teacher Community said about 1 year later:

    Thanks for this post, my friend will be so exciting to check this. I really appreciate your work over here

  27. jordan shoes said about 1 year later:

    My only complaint about the production is the handling of the chorus.

  28. online health insurance quotes said about 1 year later:

    I have found so many interesting thing in your blog and I really love by going through this post thanks for sharing the info.

  29. webcam chat script said about 1 year later:

    Aw, this is a really quality post. In theory I'd like to write like this too - taking time and real effort to make a good article... but what can I say... I procrastinate a lot and never seem to get something done.

  30. Home Restoration said about 1 year later:

    very good looking post, I hope to see more from you soon!

  31. nowGoogle.com adalah Multiple Search Engine Popular said about 1 year later:

    thanks

  32. nowGoogle.com adalah Multiple Search Engine Popular said about 1 year later:

    great info s here

  33. Watch Series said about 1 year later:

    TV Links was a user contributed online video directory for television programme's,films and music videos.

  34. VigRX Plus said about 1 year later:

    I really liked this post as it is quite informative without any filler content. Looking forward to more such posts in future. Excellent post.

  35. Vigorelle said about 1 year later:

    I really find this post up to the mark without any silly unwanted elaboration. All the information has been covered in the right manner. Thumbs up for this post!

  36. SEO Results said about 1 year later:

    Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It's always nice when you can not only be informed, but also entertained!

(leave url/email »)

   Comment Markup Help Preview comment