Check If Branch Exists with gitPython🔗

Pavol Kutaj
Apr 30, 2021

--

The aim of this how-to-guide🏁 is to demo how to check for the branch existence with gitPython

STEPS

  1. import git
  2. assign branches to a variable with
    branches = git.Git().branch("-all").split()
  3. test for membership with in or not in operator with e.g.
    >>> "master" in branches
    >>> True
  • this is returning True or False
  • this is also not throwing exceptions

SOURCES🔗

--

--

No responses yet