我想创建一个
Java程序,其中
>连接到某个Git存储库,
>将文本附加到文件,
>承诺和
>将更改推送到该存储库.
理想情况下,所有这些都应该发生在内存中.
我正在使用JGit与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();
pull.call()导致以下异常:
org.eclipse.jgit.api.errors.NoHeadException: Pull on repository without HEAD currently not supported
at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:191)
如何将存储库的内容检索到内存中的JGit存储库?