threads / discuss / 26717

rebase question

Subject: rebase question

## tl;dr

2 messages between Mar 11, 2011 and Mar 13, 2011.

replies: 1people: 2as markdown or json

Ryan Sun· Mar 11, 2011, 19:57 UTC · lore

I want to rebase the current branch B1 from origin/A1 to origin/A2 so I want to use this command git --onto origin/A2 origin/A1 B1

Q1: is this command right? (A2 is based on A1, current branch is B1,
B1 is already pushed to origin, a remote repo, and I think I will
force push B1 after rebase)
but I accidentally typed
 git --onto origin/A2 origin/A1 origin/A2
and git says
----
First, rewinding head to replay your work on top of it...
Fast-forwarded origin/base to origin/base.
----
Q2:I assume this command is safe and it didn't change anything right?
THANKS IN ADVANCE
Martin von Zweigbergk· Mar 13, 2011, 01:05 UTC · re: Ryan Sun · lore

Re: rebase question

On Fri, 11 Mar 2011, Ryan Sun wrote:
Show 7 quoted lines
> I want to rebase the current branch B1 from origin/A1 to origin/A2
> so I want to use this command
> git --onto origin/A2 origin/A1 B1
> 
> Q1: is this command right? (A2 is based on A1, current branch is B1,
> B1 is already pushed to origin, a remote repo, and I think I will
> force push B1 after rebase)

Yes, it is correct (except that the "rebase" is missing, of course). Since A2 is based on A1, you could even use "git rebase origin/A2 B1".

Show 7 quoted lines
> but I accidentally typed
>  git --onto origin/A2 origin/A1 origin/A2
> and git says
> ----
> First, rewinding head to replay your work on top of it...
> Fast-forwarded origin/base to origin/base.
> ----

I assume "origin/base" is what you called "origin/A2" above. The output is a bit confusing in this case.

I tried "git rebase [--onto origin/pu] origin/pu origin/master". That printed

Fast-forwarded origin/master to origin/pu.

which is even incorrect. It didn't (and shouldn't) update origin/master, so it obviously shouldn't say that it did either. Should be easy enough to fix. I will have a look at that when I get some time.

> Q2:I assume this command is safe and it didn't change anything right?

It detached your HEAD at origin/A2, but no commits, nor refs would have been changed or lost. You can safely checkout out B1 again if you want.

/Martin

← back to recent threads