Reputation: 2035
We have just moved over to git and we are following the fork-and-branch method for working. However, we sometimes need to work on someone else's fork's branch in my fork.
Consider this - There is a CENTRAL repo. From this repo team member A and B created FORK_A and FORK_B respectively. A is working on some feature in branch A1 existing in FORK_A. Now, B wants to work on some feature which has some dependent code in A1. How should B create a branch B1 in FORK_B from branch A1?
I thought of one solution where A creates a pull request from A1 to intermediate branch B1 where B can work. This has a problem that to keep latest changes of A1 in sync A will be required to create a pull request for each change.
Is there an easier, more elegant way of doing this? Or are we trying to do something not recommended at all?
Upvotes: 2
Views: 9637
Reputation: 2478
The general practice is to add the central repo as Upstream.
See the docs here
https://help.github.com/articles/configuring-a-remote-for-a-fork/
Then if you want to pull changes from Fork_A then B adds that as new remote. Pull the changes
See the docs about adding a remote
https://help.github.com/articles/adding-a-remote/
git pull remoteA branchName
The trick is to use rebase properly and from time to time so that all changes are in sync.
Most importantly keep your changes synced in central and merge from time to time.
Upvotes: 2
Reputation: 10174
I think that generally you don't want to fork or branch from a repo or branch that has an incomplete feature. It sounds like you would want to merge completed features upstream to the central repo or some fork on that central repo from which you could pull down to a different fork.
https://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow
Upvotes: 0