def has_ref(git, ref):
    try:
        out = git("show-ref", "--verify", "--quiet", ref)
    except sh.ErrorReturnCode:
        return False
    return out.exit_code == 0
Return true if the named branch exists
dataset/ETHPy150Open dimagi/commcare-hq/scripts/rebuildstaging.py/has_ref