I want to create a Java program, which
- connects to a certain Git repository,
- appends text to a file,
- commits and
- pushes the changes to that repository.
Ideally, all of this should happen in the memory.
I'm using JGit for interaction with Git:
InMemoryRepository repo = new InMemoryRepository(new DfsRepositoryDescription());
Git git = new Git(repo);
git.init().call();
PullCommand pull = git.pull();
StoredConfig config = git.getRepository().getConfig();
config.setString("remote", "origin", "url", "https://XXX");
config.save();
PullResult result = pull.call();
The pull.call()
results in the following exception:
org.eclipse.jgit.api.errors.NoHeadException: Pull on repository without HEAD currently not supported
at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:191)
How can I retrieve the contents of a repository into an in-memory JGit repository?