// Do not use the geogig instance after this, but the tx one!
GeogigTransaction tx = geogig.command(TransactionBegin.class).call();
try {
Optional<Ref> oldRef = tx.command(RefParse.class).setName(refspec).call();
Optional<Ref> headRef = tx.command(RefParse.class).setName(Ref.HEAD).call();
String refName = refspec;
if (oldRef.isPresent()) {
if (oldRef.get().getObjectId().equals(newCommit)) {
LOGGER.info("ref '{}' -> {} not updated, got same id", refName, newCommit);
return;