How do I fork a repo in my organization into the same organization so that I can regularly sync the fork with the upstream repository?
In this StackOverflow question Copy/fork a git repo on github into same organization the asker wanted to create two separate disconnected repos one which was cloned from the other.
How do I create a forked project which multiple people will be able to see and work on from the 1 organization?
One of the repos in our organization is a template framework which we use to build dozens of other applications. I am looking to solve the issue of when we add updates / patches to this template, the other repos are able to pull these changes.
I don't want to fork to my individual account as that would be awful visibility for the organization in the future.
I was facing a similar situation and came across this solution for cloning completed separated projects you listed. With some simple editions, you can send branches across repositories and sync them manually thru pull requests.
I already had the cloned repository from the original, but if you don't have it, follow @larsks answer to clone and create a copy of the repo:
$ git clone [email protected]:org/myrepo-original myrepo-new
$ cd myrepo-new
$ git remote set-url origin [email protected]:org/myrepo-new
$ git push origin master
After doing that, go back to the directory containing the original repository (the one where origin
still points to [email protected]:org/myrepo-original used in the example) and add a remote pointing to the cloned using the command:
$ git remote add cloned [email protected]:org/myrepo-new
Your original repo should look like this now:
$ git remote -v
origin [email protected]:org/myrepo-original (fetch)
origin [email protected]:org/myrepo-original (push)
cloned [email protected]:org/myrepo-new (fetch)
cloned [email protected]:org/myrepo-new (push)
After this, you can push
branches containing the stuff you want to the cloned
repo and create pull requests to better visualize the contents and merges.
Let's say you want to update the master
from the cloned repository with the master
from original one:
$ cd myrepo-original
$ git checkout master
$ git checkout -b master-original
$ git push cloned master-original
And from myrepo-new
on the GitHub interface create the PR using the base as master
and compare as master-original
.
Note: Although I think this would solve your problem, I would recommend based on the Further background you provided to research the possibility and turn your core/template repo on a submodule. In my opinion this makes it easier to update the core application between repos instead of "sending" branches cross repositories. =)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With