Ahmad Syarif
Ahmad Syarif

Reputation: 57

git rebase add master commit to the branch

While doing git rebase master branch_a, the commit that are coming from other branch are also included in my branch. I started with original branch state as seen below

The original branch state

after that, I executed rebase using git rebase master branch_a and then this happens

the state after rebase

I thought rebase will move the commit E root to I. is there problem with how I perform rebase?

UPDATE : I wrongly type the command, I used git rebase master branch_a

Upvotes: 2

Views: 225

Answers (1)

Enrico Campidoglio
Enrico Campidoglio

Reputation: 59923

The problem is in the command you ran:

git rebase branch_a master

This form means "checkout master and rebase it on top of branch_a".

From the documentation of git rebase:

git rebase master topic

[...] [this] form is just a short-hand of git checkout topic followed by git rebase master. When rebase exits topic will remain the checked-out branch.

What you're looking for is:

git rebase master branch_a

which means "checkout branch_a and rebase it on top of master".

Upvotes: 1

Related Questions