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.

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.
Otto, yeah, rebase is pretty much the same for git-svn or plain git. The things I mentioned above apply in both cases.
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.
Thanks for writing this up. Very helpful.
I second Charles! Thanks for writing this. Got me out of a tough and confusing spot.
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
My command prompt now always shows the branch in brackets. Like so:
So if anybody is using Linux and Git, this should be pretty handy to you as well.