10

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?

om39a
  • 1,406
  • 4
  • 20
  • 39
  • What gives you the impression that the rebase is not complete? – Jan Hudec Mar 17 '14 at 05:44
  • In git log I don't see any commits and I don't see my merges when I open file in filesystem. That is why I was thinking rebase is not yet complete. And do I need to commit after doing a rebase? – om39a Mar 17 '14 at 05:52
  • Than what you post does not show that. According to what you posted, the rebase went fine and is done. – Jan Hudec Mar 17 '14 at 05:57
  • @JanHudec Looks like rebase is completed. But why my changes merge changes are not there in files system. There are no files to do a git add except filname.orgi. – om39a Mar 17 '14 at 06:04
  • *.orig files are temp files created in process of merg. [I referred to this link](http://stackoverflow.com/questions/1251681/diff-tool-generates-unwanted-orig-files) and its clear now!! – om39a Mar 17 '14 at 13:02

1 Answers1

10

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.

Jan Hudec
  • 73,652
  • 13
  • 125
  • 172
  • Thank you for the explanation. I believe in my case rebase was success and it I could see the new branch from master as you mentioned. I will be doing a git push now to finish things off. But I don't understand that point where you are telling about **"if nobody else based anything on origin/crtdev"**. My understanding is except me, if any one else is using doing rebase on that branch? is that what it means? – om39a Mar 17 '14 at 06:18
  • I have successfully pushed the files and now my log shows (HEAD, origin/crtdev, crtdev) are in sync. – om39a Mar 17 '14 at 06:58
  • 1
    @om39a: The problem is that if anybody based further changes on the branch and you rebase it, their changes remain based on the old version of the branch. If they know and are careful, they can fix it by rebasing too, but it's rather easy to loose track of things, so it's strongly recommended not to rebase published branches. – Jan Hudec Mar 17 '14 at 07:49
  • 1
    @om39a: Well, `HEAD` is just alias for what you have checked out, so `HEAD` and `crtdev` are obviously the same and you pushed, with `-f`, so you've set `origin/crtdev` to `crtdev`. Thus they are in sync. – Jan Hudec Mar 17 '14 at 07:50
  • Hidec, That make things clear. Thank you very much!! – om39a Mar 17 '14 at 12:55