3

I use gerrit at my job, and it requires use of rebase instead of merge commits. Today I checked out a previous commit using its hash value, and when I ran the git branch command, I was informed I was on "no branch". I assume this is a detached HEAD? In any case, I rebased against my my master branch, and the console printed

Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...

Where does the '3-way merge' in this situation come from? And was the HEAD still detached after the rebase (considering the 'base-tree' statement)? Thank you.

2 Answers 2

1

Yes 'no branch' means detached HEAD

The base revision comes from doing

git merge-base <yourrevision> master

It will look at the last common ancestor (or merge point, which is considered a common ancestor even if there were manual conflicts) to establish a base version.

After a rebase, you are normally always on a new detached HEAD, IIRC. Now there are numerous ways in which to call rebase (including --onto --root) and they may behave slightly differently. So if you care to post the rebase command used, I may verify my thinking and perhaps add some comments.

3
  • 1
    A rebase does detach HEAD, but it gets reattached when it completes.
    – Cascabel
    Commented Jun 3, 2011 at 1:29
  • For some reason in my case it usually ends up deatached after completed... i get some permission denied stuff from time to time and so have to use --continue. I usually say rebase -i HEAD~10, for squashing the last commits. Any idea why it wouldnt attach itself back?
    – RaptorX
    Commented Sep 15, 2011 at 21:40
  • Usually because of merge conflicts (possible pseudo conflicts). You need to merge-tool and add, then rebase --continue (see stackoverflow.com/questions/112839/…)
    – sehe
    Commented Sep 15, 2011 at 21:47
0

As illustrated here, this error message is usually the sign of a conflict:

The conflict does not go away by itself, but in this case we fix the conflict and continue, and the original patch "Added another message" will be itself changed:

$ vi main.c
$ git add main.c
$ git rebase --continue

The key is to continue the rebase after fixing the conflict.

Not the answer you're looking for? Browse other questions tagged or ask your own question.