Benubird
Benubird

Reputation: 19487

How to move git branch up tree (reverse rebase)

Say I have a series of commits that looks like this:

h {master}
^
f g {branch1}
^ ^
d e
^/
c
^
b
^
a

I know I can move the branch1 to the end of the tree via rebase, so it would look like this: d->f->h->e->g.

But, is there any way I can move the branch UP the tree, so it looks like this?

h {master}
^
f
^
d g {branch1}
^ ^
c e
^/
b
^
a

Upvotes: 1

Views: 126

Answers (2)

dyng
dyng

Reputation: 3054

In fact, it is removing c from branch1 rather than the usual meaning of rebase. You can do it with interactive mode of rebase

git rebase -i b<SHA1>

remove the line of pick c<SHA1> and complete.

Upvotes: 2

Guillaume Darmont
Guillaume Darmont

Reputation: 5018

While being on branch1, run git rebase --onto b c branch1. This should do the job.

Upvotes: 2

Related Questions