I had seen other similar questions but not a functional code that fetchs or pulls using JGit. Could anyone help me with a small pulling example or explanation that doesn't throws a JGIT Pull NoHeadException.
Thanks in advance
I had seen other similar questions but not a functional code that fetchs or pulls using JGit. Could anyone help me with a small pulling example or explanation that doesn't throws a JGIT Pull NoHeadException.
Thanks in advance
You can see examples in JGit Cookbooks:
That is:
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());
}
}
}
That is:
try (Git git = new Git(repository)) {
PullResult call = git.pull().call();
System.out.println("Pulled from the remote repository: " + call);
}