The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.
The correct way of creating a private frok by duplicating the repo is documented here.
For this assignment the commands are:
-
Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)
git clone --bare [email protected]:raman-babich/public-private-fork-poc.git
-
Create a new private repository on Github and name it
private-private-fork-poc.If you are unable to create a private repo, you can request unlimited private repos as a student by getting the student pack from Github.
-
Mirror-push your bare clone to your new
private-private-fork-pocrepository.Replace
<your_username>with your actual Github username in the url below.cd public-private-fork-poc.git git push --mirror [email protected]:<your_username>/private-private-fork-poc.git
-
Remove the temporary local repository you created in step 1.
cd .. rm -rf public-private-fork-poc.git -
You can now clone your
private-private-fork-pocrepository on your machine (in my case in thecodefolder).cd ~/code git clone [email protected]:<your_username>/private-private-fork-poc.git
-
Add the original repo as remote.
git remote add upstream [email protected]:raman-babich/public-private-fork-poc.git
You can list all your remotes with
git remote -v. You should see:origin [email protected]:<your_username>/private-private-fork-poc.git (fetch) origin [email protected]:<your_username>/private-private-fork-poc.git (push) upstream [email protected]:raman-babich/public-private-fork-poc.git (fetch) upstream [email protected]:raman-babich/public-private-fork-poc.git (push)Update remotes:
git remote update
Create
upstream-masterbranch and configure upstream toupstream/master. Configure upstreams for branches:git checkout -b upstream-master upstream/master
upstream-masterwill be your local convenient clone of the[email protected]:raman-babich/public-private-fork-poc.gitmasterbranch. You can simplegit pullandgit pushto pull or push from[email protected]:raman-babich/public-private-fork-poc.gitmasterbranch. -
If you have new commits on your public repo and you want to sync up them with private one.
git checkout upstream-master git pull git checkout master git merge upstream-master
Or
git checkout master git pull upstream master
And resolve conflicts if they appear.
-
If move some commits from your private fork to public repo. (Just cherry pick them)
git checkout upstream-master git pull git cherry-pick <masterCommitSha> git push
Resolve conflicts if they appear.