我可以将 Git 工作副本复制到另一台机器上吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2042470/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:01:00  来源:igfitidea点击:

Can I copy a Git working copy onto another machine?

gitgit-svn

提问by Xavier Nodet

I am in the process of creating a Git working copy from our SVN server with 'git svn clone'. But this takes quite some time (we have > 20.000 revs and almost 10.000 files). I have some other machines (for other developers) that I would like to setup the same way. Will it be possible to copy the resulting files from the first machine onto others, so as to spend less time?

我正在使用“git svn clone”从我们的 SVN 服务器创建 Git 工作副本。但这需要相当长的时间(我们有 > 20.000 转和近 1​​0.000 个文件)。我有一些其他机器(供其他开发人员使用),我想以相同的方式进行设置。是否可以将生成的文件从第一台机器复制到其他机器上,从而花费更少的时间?

In other words, is there anything in a Git working copy that ties it to the machine it was created on?

换句话说,Git 工作副本中是否有任何东西将它与创建它的机器联系起来?

Thanks.

谢谢。

回答by Arkaitz Jimenez

You can copy it, everything is inside the .git folder and is not dependant on anything else.

您可以复制它,所有内容都在 .git 文件夹中,不依赖于其他任何内容。

回答by Cypherpunks

It's also worth mentioning that if you have no local changes ("git status" doesn't show anything you want to keep), you can copy onlythe .git directory and do a "git checkout ." from the (almost-empty) repository root directory at the end.

还值得一提的是,如果您没有本地更改(“git status”没有显示您想要保留的任何内容),您可以复制.git 目录并执行“git checkout”。从最后的(几乎是空的)存储库根目录。

If it's a slow link it may also be worth repacking the repository before the transfer.

如果它是一个缓慢的链接,那么在传输之前重新打包存储库也是值得的。

The only thing I worry a little bit about is if git-svn remembers some user information that you don't want to copy to the other developers.

我唯一有点担心的是 git-svn 是否记住了一些您不想复制给其他开发人员的用户信息。

回答by mipadi

Nope, it'll be fine to just copy the repo's root directory. Just make sure you get any invisible files, too, especiallythe .gitdirectory (in the project's root) which contains all the config information for the repo.

不,只需复制 repo 的根目录就可以了。只需确保您也获得了任何不可见的文件,尤其是.git包含 repo 的所有配置信息的目录(在项目的根目录中)。