Fathy AR A dev blog: journal, notes, and more...

"Forking" a Github Repo Without Forking It

How to clone a GitHub repository and not to make it a forked repository

 ·  In: Software Development  · Tagged with: Git, GitHub


This is also known as “mirroring” a repository.

Step by step process

  1. Open your terminal.

  2. Create a bare clone of the repo in your local machine.

     git clone --bare https://github.com/username/old-repo-name.git
    

    Notice the --bare parameter.

  3. Go to the newly cloned directory.

     cd old-repo-name
    
  4. Mirror-push to the new repository[^before doing this make sure that you’ve already created the new repository on GitHub].

     git push --mirror https://github.com/username/new-repo-name.git
    
  5. Remove the local repository created earlier.

     cd ..
     rm -rf old-repo-name
    

References: