我应该如何将托管的git仓库移到新的主机上? [英] How should I move a hosted git repo to a new host?

查看:180
本文介绍了我应该如何将托管的git仓库移到新的主机上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个TFS托管的git repo(例如 https://tfsfoo.com/_git ),以及我需要将它移动到另一个TFS主机(例如 https://tfsbar.com/_git



我的解决方案是执行以下操作(根据以下建议修改以使用--mirror):


  1. git clone https://tfsfoo.com/_git/proj --mirror li>
  2. 循环遍历分支(git branch -r)然后git分支 - 跟踪每个分支(如
  3. git pull

  4. git remote set-url origin https: //tfsbar.com/_git/proj

  5. git push --all - follow - tags

现在 - 我知道我可以试试看看它是否有效(我可能会在等待答案的时候),但鉴于git中的所有内容都有多种方式,我想知道是否有更好的方法 - 或者更重要的是,如果这种方法有什么问题(我对git相对来说比较陌生)。 解决方案

因为您可以通过网络访问第二台服务器,所以是的,推送是最简单的方法。



要为所有远程追踪分行创建本地分行,您可以使用我通常在 git从远程存储库中获取所有分支中使用的单行命令。



另一种方法是 git clone - 镜像 第一个仓库,并将其推送到第二个服务器在此答案中


I have a TFS hosted git repo (e.g. https://tfsfoo.com/_git), and I need to move it to another TFS host (e.g. https://tfsbar.com/_git)

My solution is to do the following (modified based on suggestion below to use --mirror):

  1. git clone https://tfsfoo.com/_git/proj --mirror
  2. Loop through branches (git branch -r) and then git branch --track each of those (as in this post)
  3. Note that I had already pushed to the new repo (without branches), so --mirror wasn't an option.
  4. git pull
  5. git remote set-url origin https://tfsbar.com/_git/proj
  6. git push --all --follow-tags

Now - I know I can just try this to see if it works (and I probably will while I wait for answers), but given that there are multiple ways to do just about everything in git, I'm wondering if there's a better way - or more importantly, if there's anything wrong with this approach (I'm relatively new to git).

解决方案

Since you have network access to the second server, then yes, pushing is the easiest way.

To create local branches for all remote tracking branches, you can use the one-liner I usually use at "git pull all branches from remote repository".

The alternative is to git clone --mirror the first repo, and push it to the second server as in this answer.

这篇关于我应该如何将托管的git仓库移到新的主机上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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