简体   繁体   中英

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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