Reputation: 1451
I am having a problem with git. So,there was one new branch(a) that was committed for review. While it was in review, another branch was created (b). Branch a was merged into the main branch dev from which a and b were created.
Now in branch b, there are some code that is present in branch a that can be used. I pulled dev branch and I did get the merged code.But when I check out to branch b to finish, those changes that were in branch a and merge into dev don't appear.
I am pretty sure I screwed up the git flow. How can branch b which is created out of dev branch those merged changes of branch a?
Upvotes: 2
Views: 653
Reputation: 2884
This is expected, Git branches are a way of working on a single code base by multiple people at the same time. To do this; it uses code base state at a given time as a reference. So when you branch b
of dev
was at a certain that was different from the branch a
.
Following should be something when you the branches look like when you create the new branch B
(2)
/------- A ---------
----(1)---- Dev ---(2)-----------------
\--------- B -----
Now somewhere along the line the branch A
is merged back to Dev
(3). So this should be what the branch should look like
/------- A ----------\
----(1)---- Dev ---(2)----(3)----------------
\--------- B -----------
Now when you're on the Dev
branch, it knows about the changes from A
(3) since it been merged back.
But branch B
don't know about this as it merged off from Dev
(2) before the branch A
(3) merged back.
To get the branch B
inline with Dev
, you've two options now.
Dev
into B
. git checkout b; git merged dev
Dev
on to B
. git checkout b; git pull --rebase origin dev
. Don't recommend this if you're a noob to git. It can sometimes go wrong in a hurry. Upvotes: 2