git clone with eclipse jgit - Java Git

Java examples for Git:jgit

Description

git clone with eclipse jgit

Demo Code


import java.io.File;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.revwalk.RevCommit;

public class GitTool {

    public static void main(String[] args) throws Throwable {

        String githubRepo = "https://github.com/yourName/pro.git";
        File localGitRepo = new File(
                "/Users/JGit/github_repo_11");

        // Clone/*from w  w w .  j a v a2s .c om*/
        Git.cloneRepository().setURI(githubRepo).setDirectory(localGitRepo)
                .call();

        Git git = Git.open(localGitRepo);

        for (RevCommit revCommit : git.log().call()) {
            System.out.println(revCommit);
            System.out.println(revCommit.getShortMessage());
            System.out.println(revCommit.getCommitterIdent().getName()
                    + " " + revCommit.getCommitterIdent().getEmailAddress()
                    + "\n");
        }

    }

}

Related Tutorials