如何使用JGit进行拉取或取出?

时间:2014-04-09 16:23:13

标签: java git fetch pull jgit

我见过其他类似的问题,但没有看到使用JGit获取或拉取的功能代码。任何人都可以通过一个小小的拉动示例或解释来帮助我,但不会抛出JGIT Pull NoHeadException。

提前致谢

1 个答案:

答案 0 :(得分:0)

您可以在JGit食谱中查看示例:

也就是说:

agent.add( `You selected ${agent.parameters['PizzaChoice']}` );

也就是说:

public static void main(String[] args) throws IOException, GitAPIException {
    try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
        System.out.println("Starting fetch");
        try (Git git = new Git(repository)) {
            FetchResult result = git.fetch().setCheckFetchedObjects(true).call();
            System.out.println("Messages: " + result.getMessages());
        }
    }
}