Checkout subfolder in git

心已入冬 提交于 2019-12-05 17:05:28

Short version:

You need to use a separate repo per top-level folder you want to give access to. See submodules for more info on how to go about doing that.

"sparse" checkouts could work, but I believe this cannot be forced upon your users, who has to clone the entire repository to local anyway, then just get a partial working directory.

(You could also setup a separate repo that would be auto-updated and push changes to that, but you lose the opportunity to merge forks and fixes from your userbase, which is sort of the point, I guess.)

Longer version: Wo The "new" distributed version control systems (Git, Mercurial, Bazaar, etc) are not built around per-folder checkout in the same fashion as SVN and CVS. Having the branching tree separate from the directory tree simplifies handling branches and merges in the revision graph, as these are more numerous than for centralized VC:es. (SVN, IMO, handle branches & merges like a sledgehammer handles opening a can of spam, much of this is due to the fact that any directory in the hierarchy can be branched/merged).

The partial checkouts feature is easy to give in centralized scenarios where you don't branch/merge, and was therefore popular in the dawn of time. You don't get that anymore, and will probably learn to be thankful for not having it. :)

Having a few subrepos/submodules of the important stuff is therefore easier. Branching the top repo is slightly more complicated though, so you need to think about how you want to set things up to make things easy for you to work with. (Maybe releasing the presentation slides is not that bad? :)

There is no way to check out just a subfolder of a repository using git.

You could make the subfolder its own repository, or distribute tarballs/zipfiles as you suggest.

As of git 1.7, there is support for "sparse checkouts" - see here - but that's only the working copy that's sparse; you'd still have to give the users the ability to clone your whole repository.

As stated in the Git Book under the submodules chapter, Git does not allow partial checkouts.

You may just keep as private your repository and move the development of src/ to a new, public one. Maybe on github, it has some community features -- e.g. bug tracking, follow -- that would simplify things for your followers.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!