Here is one way to indirectly 'forking' a repository with with private or internal visibility.
First creates a new repo (private-repo.git) in Github through the ui or cli.
Then, clone a public repo to local.
--bare option is use to make a copy all branches and tags without mapping them to the remotes origin
Then, push the local to the private repo
--mirror option is use to push all refs
Remove the local copy of public repo .git directory.
git clone --bare https://github.com/original_user/public-repo.git cd public-repo.git git push --mirror https://github.com/your_user/private-repo.git cd .. rm -rf public-repo.gitTo perform any changes,
First clone the private copy to local.
Make changes and push the changes up to private repo.
git clone https://github.com/your_user/private-repo.git cd private-repo git commit git push origin masterFor any subsequent changes on the private repo, pull it down to local
git pull origin # or git pull origin branch # or using fetch/merge git fetch origin git merge origin/master # or intended remote branchTo update from public repo to private repo.
First add the public repo to remote. Now there should be two remotes.
One for origin pointing to the private repo (your_user), and one as public pointing to public repo (original_user)
Then pull the latest codes from public to local
Then push to the private repo
To also update all the tags from the public repo to private repo
fetch the public repo tags
push the tags to private repo
cd private-repo git remote add public https://github.com/original_user/public-repo.git # check list of remote git remove -v # Creates a merge commit git pull public master git push origin master git fetch public --tags git push origin --tags # if there is a need to remove the local tag to let public tag take precendent git tag -d <tag> # if there is a need to remove the remote tag git push origin --delete <tag>
No comments:
Post a Comment