Git Commands – 2

You will learn how to move or copy git repository from one remote server to another with entire history. This is also known as git mirroring.

1.Create a bare clone of the old repository.

$ git clone --bare https://github.com/exampleuser/old-repository.git

2.Mirror-push to the new repository.

$ cd old-repository.git
$ git push --mirror https://github.com/exampleuser/new-repository.git

3.Remove the temporary local repository you created in step 1.

$ cd ..
$ rm -rf old-repository.git

Now check the new repository and you will see entire git history which was there in old repository is coppied to the new repository with all the branches and commits.

Leave a Reply

Your email address will not be published. Required fields are marked *