protected RevCommit commitFile(String filename, String contents, String branch) {
try {
Git git = new Git(db);
String originalBranch = git.getRepository().getFullBranch();
if (git.getRepository().getRef(branch) == null)
git.branchCreate().setName(branch).call();
git.checkout().setName(branch).call();
writeTrashFile(filename, contents);
git.add().addFilepattern(filename).call();
RevCommit commit = git.commit()
.setMessage(branch + ": " + filename).call();