How to git rebase a branch with the onto command?

I have noticed that the two blocks of following git commands have different behaviours and I don’t understand why.

I have an A and a B branches that diverge with one commit

---COMMIT--- (A)
\
 --- (B)

I want to rebase B branch on the lastest A (and have the commit on the B branch)

---COMMIT--- (A)
         \
          --- (B)

No problem if I do:

checkout B
rebase A

But if I do:

checkout B
rebase --onto B A

It doesn’t work at all, nothing happens. I don’t understand why the two behaviours are different.

PhpStorm GIT client uses the second syntax, and so seems to be completely broken, that’s why I ask for this syntax issue.

8 Answers
8

Leave a Comment