问题
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:
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.
来源:https://stackoverflow.com/questions/14407461/how-do-i-implement-sparse-checkout-in-jgit