我见过其他类似的问题,但没有看到使用 JGit 获取或 pull 的功能代码。谁能帮我举一个不抛出 JGIT Pull NoHeadException 的小示例或解释。
提前致谢
最佳答案
您可以在 JGit Cookbooks 中查看示例:
即:
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());
}
}
}
即:
try (Git git = new Git(repository)) {
PullResult call = git.pull().call();
System.out.println("Pulled from the remote repository: " + call);
}
关于java - 我如何使用 JGit 进行 pull 或获取?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22968462/