Check If Branch Exists with gitPython🔗
Apr 30, 2021
The aim of this how-to-guide🏁 is to demo how to check for the branch existence with gitPython
STEPS
import git
- assign branches to a variable with
branches = git.Git().branch("-all").split()
- test for membership with
in
ornot in
operator with e.g.>>> "master" in branches
>>> True
- this is returning
True
orFalse
- this is also not throwing exceptions