One way of duplicating a repository is by forking it -to do that, browse to the repository you wish to duplicate, and click the “Fork” button. The other way to duplicate a Git repository is without forking it by executing a mirror-push command to the newly created repository. In this tutorial, I’ll be explaining how to duplicate a Git Repository without forking it – that’s via mirror-push command.
Duplicate a Git Repository
In order to execute Git commands, you need to download Git Bash and install it. Once done,
Step 1: Launch Git Bash
Step 2: Let’s create a bare clone of the repository that you wish to duplicate
git clone --bare https://github.com/username/repo-you-wish-to-duplicate.git
Step 3: Duplicate a repository using mirror push command, to do that you need to change directory to the bare-cloned repository folder.
Now, mirror or duplicate the repository using the below command.
git push --mirror https://github.com/username/duplicate-repository.git
That’s it! Go to your GitHub account and view the duplicate repository.
Step 4: Well, you don’t need the bare-cloned repository in the local machine, so just go ahead and delete it.
Do you see Repository not found error while pushing the code change? Well, here are a few suggestions to help fix the issue.
Comments Leave a Comment
Hey David, for me this error appears on the end of the proccess:
“remote: GitLab: You are not allowed to force push code to a protected branch on this project.
! [remote rejected] main -> main (pre-receive hook declined)
! [remote rejected] featured-teste -> featured-teste (pre-receive hook declined)
error: failed to push some refs to ‘https://gitlab.com/myreposiroty/client-cms-teste-duplicated.git'”
Did you know what happens here?