I have a server that I'm taking down. The only thing I have left to migrate is my repository. This server is listed as the origin (master) for one of my projects. What is the proper way to move the repository to keep the history.
I have a server that I'm taking down. The only thing I have left to migrate is my repository. This server is listed as the origin (master) for one of my projects. What is the proper way to move the repository to keep the history.
This is a variation on this answer, currently suggested by gitlab to "migrate" a git repository from one server to another.
Let us assume that your old project is called existing_repo, stored in a existing_repo folder.
Create a repo on your new server. We will assume that the url of that new project is git@newserver:newproject.git
Open a command-line interface, and enter the following:
cd existing_repo
git remote rename origin old-origin
git remote add origin git@newserver:newproject.git
git push -u origin --all
git push -u origin --tags
The benefits of this approach is that you do not delete the branch that corresponds to your old server.
Remark:
git copy http://a.com/old.git http://a.com/new.git
works only for e.g. a github to github copy, i.e. remaining on the same git system. When copying from e.g. github to gerrit, this does not work.
Besides that, it's quite comfortable, as it copies branches, tags, and submodules automatically.