I have seen a lot of tutorials but I haven't found any code for getting all the files and folders in a particular branch.
I have tried this piece of code
File src = new File("C:\\Users\\Winfo\\Documents\\GitHub\\WDAS");
org.eclipse.jgit.lib.Repository repo = new FileRepositoryBuilder().readEnvironment().findGitDir(src).build();
Git git = new Git(repo);
git.checkout()
.setName("new-branch")
.setStartPoint("commit id") // commit id here
.call();
This is creating a separate Branch based on the commit id, but I need to clone the list of files and folders in a local repository based on the branch.
I am new to JGit, could someone help with my requirement. Thanks in advance
You may do something like this below to pull from a particular branch
Git.cloneRepository()
.setURI("https://github.com/eclipse/jgit.git") // your git url
.setDirectory(new File("/path/to/repo"))
.setBranchesToClone(Arrays.asList("refs/heads/specific-branch"))// give ur branch name
.setBranch("refs/heads/specific-branch")
.call();
For more information: read here
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.