Is it possible to bundle a repository using JGit?
I'm trying to do the equivalent of this git command:
git --git-dir=path/to/my/local/repo bundle create path/to/backup.bundle --all
Looking at the documentation, I'd say yes:
public class BundleWriter extends Object
Creates a Git bundle file, for sneaker-net transport to another system.
Here's an (untested) example:
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"));