Unable to finish a Git Rebase

17,279

The rebase is complete.

# On branch crtdev
# Your branch and 'origin/crtdev' have diverged,
# and have 33 and 8 different commits each, respectively.
#   (use "git pull" to merge the remote branch into yours)

See, it does not say anything about rebase in progress. The rebase has finished. The only thing it says is that crtdev and origin/crtdev have diverged, but that's exactly what it is supposed to be saying after a rebase.

You have done rebase of crtdev on master. That means you've discarded the old history of crtdev and re-created it on master. However origin/crtdev is a separate ref and still points to the old history. Your history now looks something like:

X--Y--Z...--master
 \             \
  \             A'--B'--C'--D'--E'--F'--crtdev
   \
    A--B--C--D--E--F--origin/crtdev

The revisions A'-crtdev do the same changes (sans the conflict resolution) as the A-origin/crtdev did, but they are new changes. Because they also contain the new changes from master and commit ID in git is a checksum of it's content.

Now if nobody else based anything on origin/crtdev, you just want to push out the new history. git push -f (branch names match, so arguments not needed; full command would begit push -f origin crtdev:crtdev).

If, however, somebody already used origin/crtdev, you've done the wrong thing. You should discard the results of the rebase (git reset --hard origin/crtdev) and merge instead. The problem is that if there is already other work based on the branch, it will remain to be based on it's old version. While it is possible to rebase it on the new version, it is very easy to forget and do something wrong and very confusing for the unsuspecting colleague.

Share:
17,279
om39a
Author by

om39a

software engineer in a midsize software company

Updated on July 25, 2022

Comments

  • om39a
    om39a almost 2 years

    I am currently working on a branch and want to update it with master. So I tried doing a rebase.

    current branch that I am workin on : crtdev

    I tried doing rebase like,

    git checkout crtdev
    git rebase master
    // used diff mergetool to solve merge issues
    git rebase --continue
    

    Now is says, Applying: "all commit messages that I have done in that branch"

    But after that what needs to be done?

    I checked the repo and there are no changes and when I said git status, I see merged files appearing with filename.html.orig

    -- edit When I run a git rebase --continue I get this message No rebase in progress?

    By running Git status I see this message

    # On branch crtdev
    # Your branch and 'origin/crtdev' have diverged,
    # and have 33 and 8 different commits each, respectively.
    #   (use "git pull" to merge the remote branch into yours)
    

    To complete the rebase, what needs to be done?