我有个服务器要关闭。我剩下要迁移的唯一东西是我的存储库。这个服务器被列为我的一个项目的原始(主)服务器。移动存储库以保存历史的正确方法是什么?


当前回答

看看GitHub上的这个食谱: https://help.github.com/articles/importing-an-external-git-repository

在发现git push -mirror之前,我尝试了许多方法。

效果好极了!

其他回答

我按照BitBucket上的说明移动了一个回购,所有分支都在那里。下面是#字符后面的步骤和解释:

cd path/to/local/repo
git remote remove origin # to get rid of the old setting, this was not in the BitBucket instructions
git remote add origin ssh://git@bitbucket.org/<username>/<newrepo> # modify URL as needed
git push -u origin --all # pushes _ALL_ branches in one go
git push -u origin --tags # pushes _ALL_ tags in one go

对我来说很管用。

复制一遍。就是这么简单。:)

在客户端,只需在客户端的本地repo中编辑.git/config,以便根据需要将您的遥控器指向新的URL。

应该像这样简单:

git remote set-url origin git://new.url.here

通过这种方式,您可以保留新回购的名称来源-然后将旧的推到新回购,如其他答案中详细说明的那样。假设你独自工作,你有一个本地回购,你想镜像所有的cruft,你也可以(从你的本地回购内部)

git push origin --mirror # origin points to your new repo

但请参阅“git push——mirror”是否足以备份我的存储库?(在所有不使用——镜子但一次)。

请按以下步骤操作:

git remote add new-origin <GIT URL>
git push --all new-origin
git push --tags new-origin
git remote rm origin
git remote rename new-origin origin

要添加新的回购位置,

git remote add new_repo_name new_repo_url

然后将内容推到新位置

git push new_repo_name master

最后去掉旧的

git remote rm origin

之后,你可以做什么bdonlan说,并编辑。Git /config文件修改new_repo_name为origin。如果您不删除原始(原始远程存储库),您可以简单地将更改推到新的repo with

git push new_repo_name master