Rebasing a Detached HEAD against a master branch

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.

  • Git/Gerrit Jenkins Continous Integration: How to handle rebase needs
  • Migrating a Gerrit project into a different instance of Gerrit
  • Gerrit as a review tool, not as the repository of record
  • How can I recover my Git repository for a “missing tree” error?
  • Why Gerrit is accepting pushes, it can't handle?
  • migrate a remote Git repository to a new Gerrit project
  • git svn - Unrecognized URL scheme error
  • How do I clone/pull from GitHub, but push to Kiln?
  • Setting diffmerge as visual Git difftool not working
  • opposite of 'git status' command
  • Strong access control for Gollum?
  • How to delete the old git history?
  • 2 Solutions collect form web for “Rebasing a Detached HEAD against a master branch”

    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.

    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.

    Git Baby is a git and github fan, let's start git clone.