Don't understand forking
We just set up a project with bitbucket. We put our ‘production'[P] code on a repo, and then i created a fork[m] of it, and then my co-worker[C] also created a fork of it.
[P] / \ [M] [C]
I made some changes, and created a pull request and accepted it, so [P] now has my code, [M].
Here is where I am confused. How does [C], my coworkers repo get the updated code?
2 Solutions collect form web for “Don't understand forking”
Your coworker needs to pull from P.
If you’re working on the
master branch in P, then the command would be…
git pull origin master
Note: if we are actually talking about forking (which is the act of cloning a repo on the server side) and not simple cloning, then the schema is:
BitBucket ------------[P]----------- | ^ | | | | (forked) (pull request) (forked) | | v v [M] [C] | | ----|------------------------|----- | Local workstations | | | (git clone) (git clone) | | v v [MLocal] [CLocal]
In other words,
C are on the BitBucket servers, not on
Cuser local workstations.
origin‘ would be their respective upstream repo of
CLocal, that is M or C, not
(See “What is the difference between origin and upstream”, for GitHub, but applies also for BitBucket)
This is useful for Muser because:
Musermight not want to push directly to
P(he could though, he is the owner of
Pon BitBucket), so here, repo
Macts as his “buffer”
Cuserhas no right to push on
P, so he must to fork as well
In that case, for
Cuser to see any updates on
P, he needs to add
P as a remote to
CLocal repo (ie his cloned local repo of his fork)
git remote add P https://bitbucket.org/Puser/P git pull P master
Once those new changes are integrated and tested locally (on
CLocal), they can be pushed back to
C, along with new evolutions introduced by
Cuser. Only those new modifications will be part of a pull request, for
P owner) to examine and add to P.
Muser would need to add
P as a remote to
MLocal, in order to get back any modifications from
C that were accepted into