简体   繁体   English

如何在JGit中实施稀疏签出?

[英]How do I implement sparse checkout in JGit?

I need to pull the contents of a specific sub directory in a Github Repository and put it under my own directory. 我需要在Github存储库中提取特定子目录的内容,并将其放在我自己的目录下。 After much research, it seems sparse checkouts is the way to go. 经过大量研究,似乎稀疏的结帐方式是可行的。 However, I am a little unsure, as to how to implement this using JGit. 但是,我不确定如何使用JGit来实现这一点。

1) You cannot clone only part of a repo -- for example, a repo with lib and Tests but you want to clone only the lib portion. 1)您不能仅克隆存储库的一部分-例如,具有libTests lib ,但您只想克隆lib部分。

2) You can use "git clone --depth DEPTH ..." to clone only DEPTH revisions back, but you still get the whole repo, just not all of the revisions. 2)您可以使用“ git clone --depth DEPTH ...”仅向后克隆DEPTH修订版,但是您仍然可以获得整个存储库,而并非所有修订版。 (There are other limitations, so please man git-clone first.) (还有其他限制,所以请先使用man git-clone 。)

3) You can perform git clone --bare ... , then checkout just the files that you need (the "sparse checkout" you speak of). 3)您可以执行git clone --bare ... ,然后仅签出您需要的文件(您所说的“稀疏签出”)。 (Alas, there are more steps to that method than these two...) (A,该方法比这两个步骤更多...)

Note that in (3) you will still end up with all of the history from the origin repo unless you add the --depth DEPTH argument. 请注意,在(3)中,除非添加--depth DEPTH参数,否则您--depth DEPTH获得原始存储库中的所有历史记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM