In order to develop a feature, I created a feature branch (called feature/a
).
During development of feature/a
, I found there is a existing bug, so I create a bug branch (called fix/b
) based from master.
After fixed this bug and committed, I checked out feature/a
again, and ran git rebase origin/master
. But because it depends on fix/b
, so I ran git rebase origin/fix/b
. During both rebasing, I fixed some conflicts.
Then I kept working on feature/a
, after I finished feature/a
, just before I request pull request, I realised there were many duplicated commits. Why there are many commits duplicated? I thought it might because it is because I rebased from mixed sources, but I tried to reproduce locally but not happening.
Another questions, In this case, what is the right strategy? Anyone have some thoughts?
Update #1
Sorry I forgot to mention, at that moment fix/b
still didn't merge back to master
yet. So the situation is more like the below:
master --> m1 --> m2
|\
| \
| feature/a --> a1 --> a2
|
fix/b --> b1 --> b2
Supposing I was at a2
on feature/a
, Ideally I expected the following will happen:
* git rebase master
, and the diagram should become:
--> m1 --> m2 --> a1 --> a2
* git rebase fix/b
, and the diagram should become:
--> m1 --> m2 --> b1 --> b2 --> a1 --> a2
However, in my case the diagram is more like the below: --> m1 --> m2 --> b1 --> b2 --> m1 --> m2 --> b1 --> b2 --> a1 --> a2
I couldn't reproduce in my local git repository.
My question actually is: if there are two branches (A and B), both didn't merged to master
, and one depend on the other (branch A
depends on branch B
). In this case, to keep developing branch A
, should I rebase from master
and branch B
?