A script to copy a git repository from one location to another, including all branches and tags. Particularly useful when moving a repository from one provider to another.
First, create a new repository to be the destination of the copied repository. Then execute the script:
copyrepo.sh source-repository-url destination-repository-url
That's it! Everything should be copied over to the new location.
This script follows the instructions provided by GitHub here.
-
Create a new repository to copy the source repository to.
-
Create a temporary clone of the repository you would like to copy:
git clone --bare https://github.com/exampleuser/source-repository.git
-
Push the copy to the new repository:
cd source-repository.git git push --mirror https://github.com/exampleuser/destination-repository.git
-
Remove the temporary repository:
cd .. rm -rf source-repository.git
NOTE: Additional steps are required if your repository contains Large File Storage objects.