List of usage examples for org.eclipse.jgit.api Git cloneRepository
public static CloneCommand cloneRepository()
From source file:util.Util.java
public static Git cloneProject(String uri, String folderPath) throws GitAPIException { return Git.cloneRepository().setURI(uri).setDirectory(new File(folderPath)).call(); }
From source file:wherehows.common.utils.GitUtil.java
License:Open Source License
/** * Cloning the remote git repo to local directory * @param remoteUri remote git url e.g. git://gitli.example.com/project/repo.git * @param localDir local destination clone directory * @throws IOException/*from w w w .j a v a 2 s .c o m*/ * @throws GitAPIException */ public static void clone(String remoteUri, String localDir) throws IOException, GitAPIException { //create local git directory File localGitRepo = new File(localDir); if (localGitRepo.exists()) { if (localGitRepo.isDirectory()) { // clean up directory FileUtils.cleanDirectory(localGitRepo); } else { throw new IOException("File exists: " + localDir); } } else { localGitRepo.mkdirs(); } Git g = Git.cloneRepository().setURI(remoteUri).setDirectory(localGitRepo).call(); g.close(); }