Is there a better way to find out if a local git branch exists?
I am using the following command to find out if a local git branch with branch-name exists in my repository. Is this correct? Is there a better way? Please note that I am doing this inside a script. For this reason I'd like to stay away from porcelain commands if possible. git show-ref --verify --quiet refs/heads/<branch-name> # $? == 0 means local branch with <branch-name> exists. Update Turns out there is another way . Thanks @jhuynh . git rev-parse --verify <branch-name> # $? == 0 means local branch with name <branch-name> exists. Mark Longair As far as I know, that's the best way to do it