我如何在JGit中实现稀疏结帐? [英] How do I implement sparse checkout in JGit?
问题描述
我需要在Github Repository中提取特定子目录的内容,并将其放在我自己的目录下。经过大量研究,似乎稀疏的结账是一条路。不过,我有点不确定,至于如何使用JGit来实现这一点。
1)您不能克隆部分回购 - 例如,回购包含 lib
和测试
,但您只想克隆 lib
部分。
2)你可以使用git clone --depth DEPTH ...来克隆只有深度版本,但你仍然可以得到整个回购版本,但不是所有的版本。 (还有其他限制,所以请先
man git-clone
第一个。) <3>您可以执行
git clone --bare ...
,然后检出你需要的文件(你说的稀疏检出)。 (唉,这个方法比这两个步骤还要多...)请注意,在(3)中,您仍然会得到所有来自除非你添加了 - 深度DEPTH
参数。
I need to pull the contents of a specific sub directory in a Github Repository and put it under my own directory. 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.
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.
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. (There are other limitations, so please man git-clone
first.)
3) You can perform git clone --bare ...
, then checkout just the files that you need (the "sparse checkout" you speak of). (Alas, there are more steps to that method than these two...)
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.
这篇关于我如何在JGit中实现稀疏结帐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!