如何克隆仅Git存储库的子目录? [英] How do I clone a subdirectory only of a Git repository?

查看:153
本文介绍了如何克隆仅Git存储库的子目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的Git仓库,它的根目录有两个子目录:

I have my Git repository which, at the root, has two sub directories:

/finisht
/static

当它位于 SVN / finisht 在一个位置签出,而 / static 在其他地方签出,如下所示:

When this was in SVN, /finisht was checked out in one place, while /static was checked out elsewhere, like so:

svn co svn+ssh://admin@domain.com/home/admin/repos/finisht/static static

有没有办法用Git来做到这一点?

Is there a way to do this with Git?

推荐答案

此答案已过时,仅适用于低于1.7.0(2012年2月)的git版本。请参阅下面的更新版本。

不,在Git中是不可能的。

No, that's not possible in Git.

像Git一样,这将是一项重大的努力,这意味着客户端存储库的完整性将无法得到保证。如果你有兴趣,可以在git邮件列表上搜索关于稀疏克隆和稀疏获取的讨论。

Implementing something like this in Git would be a substantial effort and it would mean that the integrity of the clientside repository could no longer be guaranteed. If you are interested, search for discussions on "sparse clone" and "sparse fetch" on the git mailinglist.

一般来说,Git社区的共识是if你有几个独立检查的目录,那么这些目录实际上是两个不同的项目,应该存在于两个不同的存储库中。您可以使用 Git Submodules 将它们粘合在一起。

In general, the consensus in the Git community is that if you have several directories that are always checked out independently, then these are really two different projects and should live in two different repositories. You can glue them back together using Git Submodules.

这篇关于如何克隆仅Git存储库的子目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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