Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to migrate GIT repository from one server to a new one

Tags:

git

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.

like image 960
cjibo Avatar asked Sep 27 '09 22:09

cjibo


People also ask

How do I transfer a repository to a new repo?

Navigate to the repository you just cloned. Pull in the repository's Git Large File Storage objects. Mirror-push to the new repository. Push the repository's Git Large File Storage objects to your mirror.

How do I move a git repository?

Transferring a repository owned by your personal accountOn your GitHub Enterprise Server instance, navigate to the main page of the repository. Under your repository name, click Settings. Click Transfer. Read the warnings and enter the repository name to confirm that you've done so.


1 Answers

To add the new repo location,

git remote add new_repo_name new_repo_url 

Then push the content to the new location

git push new_repo_name master 

Finally remove the old one

git remote rm origin 

After that you can do what bdonlan said and edit the.git/config file to change the new_repo_name to origin. If you don't remove the origin (original remote repository), you can simply just push changes to the new repo with

git push new_repo_name master 
like image 123
Koby Avatar answered Sep 18 '22 20:09

Koby