Skip to content

Instantly share code, notes, and snippets.

@sangramanand
Created February 9, 2018 04:15
Show Gist options
  • Save sangramanand/1aed1fa738b678c94bdbb81f871195b9 to your computer and use it in GitHub Desktop.
Save sangramanand/1aed1fa738b678c94bdbb81f871195b9 to your computer and use it in GitHub Desktop.
package com.tut.jgit;
import java.io.File;
import org.eclipse.jgit.api.CloneCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
public class GitTester {
public static void main(String[] args) {
System.out.println("Hello World!!!");
File gitDir = new File("D:\\anand\\git_test_repos");
try {
CloneCommand cloneCommand = Git.cloneRepository();
cloneCommand.setURI("https://github.com/sangramanand/JP-Multithreading.git");
cloneCommand.setDirectory(gitDir);
cloneCommand.setCredentialsProvider( new UsernamePasswordCredentialsProvider( "sangramanand", "indavest*38" ) );
cloneCommand.call();
System.out.println("done");
} catch (GitAPIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment