Skip to content

Instantly share code, notes, and snippets.

@vietnguyengit
Forked from 0xjac/private_fork.md
Created June 20, 2024 02:48
Show Gist options
  • Save vietnguyengit/fe4d85d3a8704667ff253a1cdfc310ef to your computer and use it in GitHub Desktop.
Save vietnguyengit/fe4d85d3a8704667ff253a1cdfc310ef to your computer and use it in GitHub Desktop.
Create a private fork of a public repository

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:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)
git clone --bare [email protected]:usi-systems/easytrace.git
  1. Create a new private repository on Github and name it easytrace.

If you are unable to create a private repo, you can request unlimited private repos as a studant by getting the student pack from Github.

  1. Mirror-push your bare clone to your new easytrace repository.

Replace <your_username> with your actual Github username in the url below.

cd easytrace.git
git push --mirror [email protected]:<your_username>/easytrace.git
  1. Remove the temporary local repository you created in step 1.
cd ..
rm -rf easytrace.git
  1. You can now clone your easytrace repository on your machine (in my case in the code folder).
cd ~/code
git clone [email protected]:<your_username>/easytrace.git
  1. If you want, add the original repo as remote to fetch (potential) future changes. Make sure you also disable push on the remote (as you are not allowed to push to it anyway).
git remote add upstream [email protected]:usi-systems/easytrace.git
git remote set-url --push upstream DISABLE

You can list all your remotes with git remote -v. You should see:

origin	[email protected]:<your_username>/easytrace.git (fetch)
origin	[email protected]:<your_username>/easytrace.git (push)
upstream	[email protected]:usi-systems/easytrace.git (fetch)
upstream	DISABLE (push)

When you push, do so on origin with git push origin.

To pull changes from upstream:

 git fetch upstream
 git rebase upstream/master
 ```
 And solve the conflicts if any
  1. Make your easytrace repo available in your Vagrant VM by adding the following to your Vagrantfile

Replace "~/code/easytrace" with your local path to the easytrace repo.

config.vm.synced_folder "~/code/easytrace", "/easytrace"
  1. Reload your VM to enable the synced folder (in the folder containing your Vagrant file).
vagrant reload 
  1. The easytrace repo is available at /easytrace once you ssh into the machine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment