Example usage for org.eclipse.jgit.api Git cloneRepository

List of usage examples for org.eclipse.jgit.api Git cloneRepository

Introduction

In this page you can find the example usage for org.eclipse.jgit.api Git cloneRepository.

Prototype

public static CloneCommand cloneRepository() 

Source Link

Document

Return a command object to execute a clone command

Usage

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();
}