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.

  • “Migrating” existing Git repository to Gerrit Code Revision
  • Using Netbeans to push changes for Gerrit review
  • Problems using pygerrit.rest
  • Gerrit event on Jenkins doesn't trigger automatically on git push
  • Check if all commits to one GIT branch have been cherry picked to another
  • How to get rid of false dependencies in gerrit
  • Git color code for contributor page
  • git ,how to go back?
  • How do I update my local branch of forked repo
  • What's so great about git?
  • Display the Authors and commit message for commits that cause a conflict
  • Push to master commit made on a detached head
  • 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.