git clone子文件夹

本文探讨了如何仅克隆Git仓库的一个子目录。虽然Git官方并不支持直接克隆子目录,但提到了Git 2.19版本开始实现的部分支持。文章建议使用Git子模块或者按照Stack Overflow上的建议来处理这种情况。作者提到了GitHub可能不支持Git服务器的某些功能,因此推荐关注sparse clone和sparse fetch的相关讨论。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近想git clone 一个项目的说明下来,这个项目说明又分为两种语言的,如图

但是我只想clone en version to my local repository

看了下stackover flow  

/////////////////////////////////////////////////////////////////////////////////////////////////////

EDIT: As of Git 2.19, this is finally possible, as can be seen in this answer: https://stackoverflow.com/a/52269934/2988.

Consider upvoting that answer.

Note: in Git 2.19, only client-side support is implemented, server-side support is still missing, so it only works when cloning local repositories. Also note that large Git hosters, e.g. GitHub, don't actually use the Git server, they use their own implementation, so even if support shows up in the Git server, it does not automatically mean that it works on Git hosters. (OTOH, since they don't use the Git server, they could implement it faster in their own implementations before it shows up in Git server.)


No, that's not possible in 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.

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.

说了那么多,我不太懂他的clientside 反正这个高赞回答是说不可以,而且建议每个项目分开然后再用git submodules 的方式去粘合起来。

然后后面还有介绍了其他很多方法的,但是这个不重要

https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository

下面的都是git server都是自己initailize 的但是github的server 的implementation不清楚

不过我之前有看过想multigit这种东西。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值