我有个服务器要关闭。我剩下要迁移的唯一东西是我的存储库。这个服务器被列为我的一个项目的原始(主)服务器。移动存储库以保存历史的正确方法是什么?
当前回答
复制一遍。就是这么简单。:)
在客户端,只需在客户端的本地repo中编辑.git/config,以便根据需要将您的遥控器指向新的URL。
其他回答
我只是在一个简单的指导列表中转发别人说过的话。
Move the repository: Simply login to the new server, cd to the parent directory where you now want to hold the repository, and use rsync to copy from the old server: new.server> rsync -a -v -e ssh user@old.server.com:path/to/repository.git . Make clients point to the new repository: Now on each client using the repository, just remove the pointer to the old origin, and add one to the new one. client> git remote rm origin client> git remote add origin user@new.server.com:path/to/repository.git
看看GitHub上的这个食谱: https://help.github.com/articles/importing-an-external-git-repository
在发现git push -mirror之前,我尝试了许多方法。
效果好极了!
您可以使用git-copy复制所有历史记录的回购。
git copy http://a.com/old.git http://a.com/new.git
如果你想把一个#git仓库从一个服务器迁移到一个新的服务器,你可以这样做:
git clone OLD_REPOSITORY_PATH
cd OLD_REPOSITORY_DIR
git remote add NEW_REPOSITORY_ALIAS NEW_REPOSITORY_PATH
#check out all remote branches
for remote in `git branch -r | grep -v master `; do git checkout --track $remote ; done
git push --mirror NEW_REPOSITORY_PATH
git push NEW_REPOSITORY_ALIAS --tags
旧存储库中的所有远程分支和标记将被复制到新的存储库中。
单独运行该命令:
git push NEW_REPOSITORY_ALIAS
只复制一个主分支(只跟踪分支)到新的存储库。
这在其他答案中也有部分体现。
git clone --mirror git@oldserver:oldproject.git
cd oldproject.git
git remote add new git@newserver:newproject.git
git push --mirror new
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式
- git pull -rebase和git pull -ff-only之间的区别