Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
  2. 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.

  3. 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<your_username>/easytrace.git
  4. Remove the temporary local repository you created in step 1.

    cd ..
    rm -rf easytrace.git
  5. You can now clone your easytrace repository on your machine (in my case in the code folder).

    cd ~/code
    git clone<your_username>/easytrace.git
  6. 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
    git remote set-url --push upstream DISABLE

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

    origin<your_username>/easytrace.git (fetch)
    origin<your_username>/easytrace.git (push)
    upstream (fetch)
    upstream	DISABLE (push)

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

    When you want to pull changes from upstream you can just fetch the remote and rebase on top of your work.

      git fetch upstream
      git rebase upstream/master

    And solve the conflicts if any

  7. 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"
  8. Reload your VM to enable the synced folder (in the folder containing your Vagrant file).

    vagrant reload 
  9. The easytrace repo is available at /easytrace once you ssh into the machine.


This comment has been minimized.

Copy link

kolosek commented Nov 24, 2018

Great, thanks!


This comment has been minimized.

Copy link

aksel commented Nov 29, 2018

I've been using this a lot. Thanks!


This comment has been minimized.

Copy link

paulc4 commented Dec 7, 2018

Thanks for this. Pity github made it so unnecessarily complicated.


This comment has been minimized.

Copy link

ivanrodjr commented Dec 14, 2018

Amazing, thanks.


This comment has been minimized.

Copy link

ravicious commented Aug 14, 2019

Nowadays you should be able to just use the Import a Repository feature. Not sure if you can import someone's repo straight away, but I first did a public fork and then imported that as private.


This comment has been minimized.

Copy link

rromanchuk commented Aug 29, 2019

@ravicious can confirm it works directly


This comment has been minimized.

Copy link

kamalojasv181 commented Dec 2, 2019

When i make a private fork. can i later make pull requests to the original repository?


This comment has been minimized.

Copy link

georgezim85 commented Mar 30, 2020

Saved my life. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.