【发布时间】:2020-12-13 00:22:39
【问题描述】:
是否可以使用 JGit 捆绑存储库?
我正在尝试执行与此 git 命令等效的操作:
git --git-dir=path/to/my/local/repo bundle create path/to/backup.bundle --all
【问题讨论】:
标签: git jgit git-bundle
是否可以使用 JGit 捆绑存储库?
我正在尝试执行与此 git 命令等效的操作:
git --git-dir=path/to/my/local/repo bundle create path/to/backup.bundle --all
【问题讨论】:
标签: git jgit git-bundle
看着documentation,我会说yes:
public class BundleWriter extends Object创建一个 Git 捆绑文件,用于将运动鞋网传输到另一个系统。
这是一个(未经测试的)示例:
Repository repo = new FileRepositoryBuilder()
.setGitDir(new File("path/to/my/local/repo/.git"))
.build();
BundleWriter bundle = new BundleWriter(repo);
for (Ref ref : repo.getRefDatabase().getRefs()) {
bundle.include(ref);
}
bundle.writeBundle(
new NullProgressMonitor(),
new FileOutputStream("path/to/backup.bundle"));
【讨论】:
NullProgressMonitor() 不适用于我的特定 API 版本(5.8.1.202007141445-r)。我改用new EmptyProgressMonitor() {}