Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to finish a Git Rebase

Tags:

git

git-rebase

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?

like image 663
om39a Avatar asked Mar 17 '14 05:03

om39a


People also ask

How do I finish git rebasing?

For each change you make, you'll need to perform a new commit, and you can do that by entering the git commit --amend command. When you're finished making all your changes, you can run git rebase --continue .

How do I save after rebase?

Press esc to exit edit mode and type :wq to save the file. Note: If you made changes to the file that you do not want to save, type :q! to force quit. The interactive rebase will be applied.

How do I abort a rebase editor?

To do this, simply delete all commits and actions (i.e. all lines not starting with the # sign) and the rebase will be aborted!


1 Answers

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.

like image 78
Jan Hudec Avatar answered Sep 24 '22 20:09

Jan Hudec