To create a duplicate of a repository without forking, you need to run a special clone command against the original repository and mirror-push to the new one. This works with any git repository, not just ones hosted on GitHub.

In the following cases, the repository you're trying to push to--like exampleuser/new-repository orexampleuser/mirrored--should already exist on GitHub. Visit the Creating a new repository guide for more information.

Mirroring a repository

To make an exact duplicate, you need to perform both a bare-clone and a mirror-push.

Open up the command line, and type these commands:

git clone --bare https://github.com/exampleuser/old-repository.git# Make a bare clone of the repositorycd old-repository.gitgit push --mirror https://github.com/exampleuser/new-repository.git# Mirror-push to the new repositorycd ..rm -rf old-repository.git# Remove our temporary local repository

If you want to mirror a repository in another location, including getting updates from the original, you can clone a mirror and periodically push the changes.

git clone --mirror https://github.com/exampleuser/repository-to-mirror.git# Make a bare mirrored clone of the repositorycd repository-to-mirror.gitgit remote set-url --push origin https://github.com/exampleuser/mirrored# Set the push location to your mirror

As with a bare clone, a mirrored clone includes all remote branches and tags, but all local references will be overwritten each time you fetch, so it will always be the same as the original repository. Setting the URL for pushes simplifies pushing to your mirror. To update your mirror, fetch updates and push, which could be automated by running a cron job.

git fetch -p origingit push --mirror