首页 > 解决方案 > 如何从私人仓库下载拉取请求?

问题描述

我想使用 java 从我有令牌的私人仓库下载拉取请求。

阅读Jgit,我没有找到办法。

有人对此有任何想法吗?

标签: javagithubjgit

解决方案


链接中,您可以阅读有关此问题的更多信息。

private String localPath;
private Repository localRepo;
private Git git;

localPath = "/home/test/git_repo_test";
remotePath = "https://github.com/test/repo_1.git";

try {
    localRepo = new FileRepository(localPath + "/.git");
} catch (IOException e) {
    e.printStackTrace();  
}
git = new Git(localRepo);

PullCommand pullCmd = git.pull();
try {
    pullCmd.call();
    PullResult result = pullCmd.call();
    FetchResult fetchResult = result.getFetchResult();
    MergeResult mergeResult = result.getMergeResult();
    mergeResult.getMergeStatus();  // this should be interesting
} catch (GitAPIException e) {
    e.printStackTrace();  
}

推荐阅读