如何在 JGit 中做一个 "git bundle create --all"?
How to do a "git bundle create --all" in JGit?
是否可以使用 JGit 捆绑存储库?
我正在尝试执行与此 git 命令等效的操作:
git --git-dir=path/to/my/local/repo bundle create path/to/backup.bundle --all
查看 documentation, I'd say yes:
public class BundleWriter
extends Object
Creates a Git bundle file, for sneaker-net transport to another system.
这是一个(未经测试的)示例:
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"));
是否可以使用 JGit 捆绑存储库?
我正在尝试执行与此 git 命令等效的操作:
git --git-dir=path/to/my/local/repo bundle create path/to/backup.bundle --all
查看 documentation, I'd say yes:
public class BundleWriter extends Object
Creates a Git bundle file, for sneaker-net transport to another system.
这是一个(未经测试的)示例:
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"));