Skip to contentSkip to conversation

Question about git rebase --onto

DISCUSSION Pascal Obry 3 participants 12 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

It seems to me that:

   $ git co topic
   $ git rebase --onto master topic~2 topic

Used to do the job and rebase the topic branch as expected. Today when I tried with 1.7.0.rc1.10.gb8bb after the rebase above I was left on a detached head.

Is my recollection wrong? Has this been changed recently?

Thanks,
Pascal.

Signature · 8 lines
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B
#1 lore raw
Quoted 10 lines · Pascal Obry

It seems to me that:

   $ git co topic
   $ git rebase --onto master topic~2 topic

Used to do the job and rebase the topic branch as expected. Today when I tried with 1.7.0.rc1.10.gb8bb after the rebase above I was left on a detached head.

Is my recollection wrong? Has this been changed recently?

Either a recent bug or a user error, I think, as we didn't intend to change. My quick manual test didn't show such a bug but rebase is one of the areas that acquired new code recently.

Possible user errors I can think of are:

- If 'topic' is not a local branch, the result will be on a detached HEAD, as you are starting from a detached HEAD (i.e. 'topic' could be a tag);

- Until you resolved and said "rebase --continue" (or --skip) to allow it to conclude the rebase when the operation conflicted, you would be on a detached HEAD.

#2 lore raw

Junio,

Quoted 5 lines

Possible user errors I can think of are:

- If 'topic' is not a local branch, the result will be on a detached HEAD, as you are starting from a detached HEAD (i.e. 'topic' could be a tag);

I'm not on this case.

Quoted 3 lines

- Until you resolved and said "rebase --continue" (or --skip) to allow it to conclude the rebase when the operation conflicted, you would be on a detached HEAD.

I'm not in this case either.

Pascal.

Signature · 8 lines
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B
#3 lore raw
Quoted 5 lines · Pascal Obry
Quoted 2 lines

Possible user errors I can think of are:
...

I'm not on this case.
...
I'm not in this case either.

Thenk there are some _other_ differences between your situation and what I can construct from your problem description:

It seems to me that:

$ git co topic
$ git rebase --onto master topic~2 topic

Used to do the job and rebase the topic branch as expected....

which I tried myself before giving you a reply, and I didn't end up on a detached HEAD. But I cannot guess what that difference you are not telling us is (and you probably don't know it either, I suspect).

Writing reproducible test case would be a great way to diagnose this.

#4 lore raw

Junio,

Quoted 1 line

Writing reproducible test case would be a great way to diagnose this.

I just can't reproduce now! I've tried on a second machine starting from the same repository state and still can't reproduce! So either I was in really bad shape last night or it was some kind of transient problem on my Cygwin/Git system.

Sorry for the noise.

Pascal.

Signature · 8 lines
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B
#5 lore raw
Quoted 8 lines · Pascal Obry
Quoted 1 line

Writing reproducible test case would be a great way to diagnose this.

I just can't reproduce now! I've tried on a second machine starting from the same repository state and still can't reproduce! So either I was in really bad shape last night or it was some kind of transient problem on my Cygwin/Git system.

Sorry for the noise.

Don't be sorry. We need to know about issues, and sporadic failures, if they are real, are the ones that affects people the worst way.

Thanks for spending time to reproduce---and please do report (and preserve the reproducible state if possible) when you see a breakage (like this one, or some other form) next time.

#6 lore raw

Junio,

Quoted 3 lines

Thanks for spending time to reproduce---and please do report (and preserve the reproducible state if possible) when you see a breakage (like this one, or some other form) next time.

I have a reproducer this time.

$ git --version
git version 1.7.0.14.g7e948
$ git clone http://git.sv.gnu.org/r/v2p.git
$ cd v2p/
$ git branch v3.1 origin/v3.1
$ git co -b po/new-context-support origin/po/new-context-support
$ git cherry -v master po/new-context-support
+ bb8647179385ecf2a5053da9a4af9e24437a5b34 Modifications to use the new
AWS's context implementation.
+ 12db018f5a448869b1679550cb2fd0e33336a6c9 Minor reformatting.
+ f7888edb7572ca6d62f35e594d231c7974bc9515 Fix testsuite to pass with
the new context support.
$ git rebase --onto v3.1 HEAD~3 HEAD

At this point I'm on a detached HEAD.

$ git status
# Not currently on any branch.
nothing to commit (working directory clean)

Let me know if you need additional information.

Pascal.

Signature · 8 lines
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B
#7 lore raw

Hi,

Quoted 1 line · Pascal Obry
$ git clone http://git.sv.gnu.org/r/v2p.git

in case anyone is wondering, the equivalent git:// url is

git://git.sv.gnu.org/v2p.git

Quoted 1 line
$ git rebase --onto v3.1 HEAD~3 HEAD

Why do you add the last parameter ("HEAD")? If I run the rebase without it, it works fine (ie. not on a detached HEAD).

Signature · 2 lines
Cheers,
Ray Chuan
#8 lore raw

Tay,

Quoted 2 lines

Why do you add the last parameter ("HEAD")? If I run the rebase without it, it works fine (ie. not on a detached HEAD).

Right, without the final HEAD it is working. But it ought to work with it too. Hence my report.

Pascal.

Signature · 8 lines
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B
#9 lore raw

Hi,

Quoted 5 lines · Pascal Obry
Quoted 2 lines

Why do you add the last parameter ("HEAD")? If I run the rebase without it, it works fine (ie. not on a detached HEAD).

Right, without the final HEAD it is working. But it ought to work with it too. Hence my report.

In your original report though, you didn't say "HEAD"; you used a branch. I quote:

Quoted 5 lines · Pascal Obry

It seems to me that:

  $ git co topic
  $ git rebase --onto master topic~2 topic

I'm not trying to nit-pick, but it does matter - "git rebase --onto foo baz~x baz" and "git rebase --onto foo HEAD~x HEAD" are quite different.

According to the docs, the last parameter <branch> specifies the branch to checkout to first before the rebasing takes place. Therefore, I believe the behaviour you're experiencing when you specify "HEAD" for the <branch> parameter is correct - git does a "git checkout $(git rev-parse HEAD)", so you start the rebase on a detached HEAD.

Signature · 2 lines
Cheers,
Ray Chuan
#10 lore raw

Tay,

Quoted 3 lines

I'm not trying to nit-pick, but it does matter - "git rebase --onto foo baz~x baz" and "git rebase --onto foo HEAD~x HEAD" are quite different.

Ok, so this was a misunderstanding on my side.

Indeed using:

$ git rebase --onto v3.1 po/new-context-support~3 po/new-context-support

Works fine! Obviously still learning Git :)

Thanks.

Pascal.

Signature · 8 lines
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B
#11 lore raw
In reply to Junio C Hamano
Quoted 9 lines · Junio C Hamano

Possible user errors I can think of are:

- If 'topic' is not a local branch, the result will be on a detached HEAD, as you are starting from a detached HEAD (i.e. 'topic' could be a tag);

- Until you resolved and said "rebase --continue" (or --skip) to allow it to conclude the rebase when the operation conflicted, you would be on a detached HEAD.

Just to clarify, these things are _not_ errors at all. What I meant by "user error" was to notice that the HEAD is detached in these cases (which is not an error) and panicking (which is). Both of these are normal procedures and sane states.