如何将GIT存储库从一台服务器迁移到新服务器 [英] How to migrate GIT repository from one server to a new one

查看:125
本文介绍了如何将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.

推荐答案

要添加新的回购库位置,

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

之后,您可以执行bdonlan所说的并编辑.git / config文件来更改new_repo_name来源。如果您不删除原始地址(原始远程存储库),您可以简单地使用

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

这篇关于如何将GIT存储库从一台服务器迁移到新服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆