Skip to content

Instantly share code, notes, and snippets.

Last active November 30, 2023 00:01
Star You must be signed in to star a gist
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.

Copy link

Thank you. Step 6 should contain cd easytrace ;-)

Copy link

Thank you. very helpful 💡💡

Copy link

Thank you!

Copy link

the one thing - it is not forking but duplicating, it means - you wouldn't be able to create a pull request

Copy link

Very useful, thank you a lot! 👍

Copy link

PabloC commented Aug 18, 2022

Thank you, this is great!

Copy link

nestvor commented Sep 23, 2022

Very nice, thank you!

Copy link

Thank you very much for this useful guide.
Is it possible to make a pull request to the remote public repo from your private fork/mirror?
If so, how would you do it?
Thank you
Best regards


It's a useful guide. But it's not up to date for this case: "Mirroring a repository that contains Git Large File Storage objects"
Better to check the GitHub Documentation.

Copy link

machist commented Jan 15, 2023

Thank you very much for this.
Is it possible to create a mirror of specific branch ?

Copy link

marwand commented Jan 22, 2023

Thank you, sir!

Copy link

Grato! :)

Copy link

Copy link

iocmet commented Mar 23, 2023


Copy link

marchev commented May 10, 2023


Copy link


Copy link

Petit filou !

Copy link

ofey404 commented Jun 27, 2023

Great job bro!

Copy link

kevherro commented Aug 1, 2023

Thank you!

Copy link

Really helpful, spent hours looking for this exact guide!

Copy link

Liuhaai commented Aug 23, 2023


Copy link

Great tutorial.
Follow up question though. How would I go about making a pull request from my private form to the upstream? Normally when you form there's a button in GitHub to allow you to do this but since this is done manually the GitHub linking isn't there. 🤔

Copy link

Thank you

Copy link

Thanks 😃

Copy link

Thx :)

Copy link

DLohn commented Oct 4, 2023

According to this entry on the GitHub Docs, using GitHub's forking method means that you lose access to your fork if the source repo goes private and you are not authorized to view the now private repo. Making a private fork with this method seems like a no-brainer if you don't use backups and want to access your changes.

Copy link

This is immensely useful thanks a lot!!

Copy link

This is immensely useful thanks a lot!! also works! 😅

Copy link

This is a game changer, thank you so much!

Copy link

Great tutorial! Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment