I would advise (if none has already pulled from B):
What you have is a Branch A
with new evolution and possible commits done in the upstream repo:
a--a--a (origin/A)
/
a--a--a A
\
b--b--b (B, local branch)
First make sure A
is up-to-date with the upstream repo content: origin/A
:
git checkout A
git pull
That will give you:
a--a--a--a--a--a (A, origin/A)
\
b--b--b (B, local branch)
Then You would rebase your local modifications done on B
on top of A
(I suppose here that A
has an upstream branch, meaning it does track origin/A
, which you can check with git branch -avvv
)
git checkout B
git rebase A
Which gives you:
a--a--a--a--a--a (A, origin/A)
\
b'--b'--b' (B, local branch)
Note that changes the history of B
, so if B
was already pushed, you would have to push --force origin B
, which can be dangerous if others already started working on B
.
See (for more on the rebase tricks):
Note: "fork a branch" isn't the recommended expression, since fork is more commonly used to refer to a cloned repo on the server side: see "Git fork is git clone?".
Instead, you would say: "I branched A
and created B
": the operation is "branching" (not "forking").