将git仓库移到第二台计算机上? [英] Moving a git repo to a second computer?

查看:118
本文介绍了将git仓库移到第二台计算机上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的本地git回购项目,我想将这个项目(文件夹等)移动到另一台计算机上,并从现在开始工作。我不想在旧机器上留下任何东西(当然除了我的其他git项目)。我希望它能够像我一直在使用新机器一样。



我可以简单地将所有文件移动到该计算机上吗?钥匙问题?我应该在两台机器上拥有相同的密钥吗?如果简单地移动所有文件夹都无法完成,我该怎么办?我想避免设置和学习使用服务器的麻烦,因为这看起来很复杂,我不想改变我的工作流程。 解决方案

对于您的情况,最好的方法是将文件夹(复制,scp,cp,robocopy - 无论哪一个)复制到新计算机并删除旧文件夹。



我完全不同意@Pablo Santa Cruz的观点,即克隆是您所做事情的典范。不它不是。为了达到这个目的,我为什么不喜欢克隆:



    >
  • 它为克隆存储库中的每个分支创建远程跟踪分支。您正在移动,旧的回购已经失效。

  • 任何远程分支和其他引用都被完全忽略。
  • 如果您有任何钩子,您就不会获得钩子,您可能会忘记它们已经拥有它们。 git reflog或其他方式。可能不是一个大问题,特别是如果repo充当服务器,但需要注意的地方。


如果您搜索备份git repo的方法,那么git clone将不在最佳答案中。所以它不应该用于移动回购!我也觉得只是一个 git clone 不能作为正确的答案,因为 git clone --mirror 选项,保留仓库,这意味着 git clone 仓库不同于 git clone --mirror 回购(除了裸露之外,差异大部分是我上面提到的)。我会做一个副本,因为我知道我用复制的回购所得到的相同的回购!



当考虑git clone:


  1. git在克隆时做了一些优化,速度更快

  2. 在新机器上有不同的git版本,并且副本可能会使repo在其他版本中不可用(现在不太常见)。但实际上这可能是另一个复制亲,因为这会告诉你,新电脑有不同的git版本。


I have a project with a simple local git repo, and I want to move this project (folders etc.) to another computer and work from there from now on. I don't want to have anything left on the old machine (except of course my other git projects). I want it to be as if I have been working from the new machine all along.

Can I simply move all the files over to that computer, or will there be a problem with keys? Should I have the same key across two machines? If simply moving all the folders can't be done, what should I do? I want to avoid the hassle of setting up and learning to use a server, since this seems complicated and I don't want to alter my workflow.

解决方案

For your case, the best way to do it is to copy over the folder (copy, scp, cp, robocopy - whichever) to the new computer and delete the old folder.

I completely disagree with @Pablo Santa Cruz that cloning is the paradigm for what you are doing. No it is not. You are moving a repo to a new computer.

Why I don't like clone for this purpose:

  • It creates remote-tracking branches for each branch in the cloned repository. You are moving, and the old repo is defunct.
  • Any remote branches and other refs are completely ignored.
  • You don't get your hooks if you had any and you might forget that you had them!
  • You cannot get "lost" commits etc using git reflog or other means. Might not be a huge issue, especially if the repo acted as a server but something to be aware of.

If you search for ways to backup a git repo, git clone wouldn't be in the top answers. So it shouldn't be used for moving a repo! I also feel that just a git clone cannot be a proper answer because git clone has the --mirror option, which preserves the repo, meaning that a git clone repo is different from git clone --mirror repo (apart from being bare, the differences are mostly those I mentioned above). I would do a copy because I know what I get with the copied repo - the same repo!

When to consider git clone:

  1. It is faster as git does some optimization while cloning
  2. You might have different git version on the new machine and a copy might make the repo unusable in the other version (not very common nowadays). But actually this can be another pro for copying, since this would inform you that that the new computer has a different git version.

这篇关于将git仓库移到第二台计算机上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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