If you want to move from one Git server to another, you will need to migrate your Git repositories.
This note shows how to migrate a Git repository with all its history, branches and tags from one Git server to another.
This method is simple, straightforward and can be used to move you Git repository to GitHub, GitLab, Bitbucket or any other Git server.
Cool Tip: Create a new repository on GitLab from a command line! Read more →
Migrate Git Repository
--mirror option to clone your Git repository with all the history, branches and tags to a temporary directory:
$ git clone --mirror <OLD_REPO_URL> temp-dir
Go to that directory and change the old repository URL to the new one:
$ cd temp-dir $ git remote set-url origin <NEW_REPO_URL>
git push with the
--mirror option to move your Git repository with all the history, branches and tags to another repository:
$ git push --mirror origin
⌛ The migration to another repository may take some time. It depends on the size of the repository and the number of branches.
The temporary directory can be deleted now and the repository can be cloned from the new remote server using the regular
git clone command:
$ cd .. $ rm -rf temp-dir $ git clone <NEW_REPO_URL>
Cool Tip: How to list all the remote and local branches in Git! Read more →