How to Duplicate a GitHub Repo with History

Damith Neranjan Samarakoon
Javarevisited
Published in
2 min readFeb 26, 2023
Photo by Roman Synkevych 🇺🇦 on Unsplash

Duplicating a GitHub repository with history is a common task for developers who want to create a copy of an existing repository. Whether it is for backup purposes or to work on a different version of the same codebase, it is important to ensure that the history of the repository is maintained. In this blog post, we will go over the steps to duplicate a GitHub repo with history.

Step 1: Create a new repository

The first step is to create a new repository where you will duplicate the original repository. To create a new repository, log in to your GitHub account, and click on the plus icon in the top right corner. From the drop-down menu, select “New repository.” Give your new repository a name, and select the appropriate settings for your repository.

Step 2: Clone the original repository

The next step is to clone the original repository to your local machine. To do this, open your terminal and navigate to the directory where you want to clone the repository. Once you are in the correct directory, enter the following command:

git clone --mirror <original-repository-url>

Replace <original-repository-url> with the URL of the original repository that you want to clone.

This command will create a mirror copy of the original repository on your local machine, including all of its history.

Step 3: Push the cloned repository to the new repository

The next step is to push the cloned repository to the new repository that you created in Step 1. To do this, navigate to the cloned repository on your local machine using the terminal and enter the following command:

cd <cloned-repository-name>
git remote set-url --push origin <new-repository-url>
git push --mirror

Replace <cloned-repository-name> with the name of the cloned repository, and <new-repository-url> with the URL of the new repository that you created in Step 1.

This command will push the cloned repository, including all of its history, to the new repository that you created in Step 1.

Step 4: Verify the new repository

Finally, navigate to the new repository on your GitHub account and verify that all of the history from the original repository has been duplicated.

Conclusion,

Duplicating a GitHub repository with history is a straightforward process that can be completed in just a few steps. By following these steps, you can create a duplicate of an existing repository without losing any of its history. This can be useful for a variety of purposes, including backup and versioning.

Thanks for reading..!! :-) .

--

--

Damith Neranjan Samarakoon
Javarevisited

I’m an Engineering Lead @Persistent System, blogger,thinker, husband & father of “little angle”. passionate about Technology,Engineering and Learning.