code: def get_branches(self, local=True, remote_branches=True):
          
  
          if not self.repo.remotes:
              remote_branches = False
  
          branches = []
  
          if remote_branches:
  
              # Remote refs.
              try:
                  for b in self.remote.refs:
                      name = '/'.join(b.name.split('/')[1:])
  
                      if name not in legit_settings.forbidden_branches:
                          branches.append(Branch(name, is_published=True))
              except (IndexError, AssertionError):
                  pass
  
          if local:
  
              # Local refs.
              for b in [h.name for h in self.repo.heads]:
  
                  if (not remote_branches) or (b not in [br.name for br in branches]):
                      if b not in legit_settings.forbidden_branches:
                          branches.append(Branch(b, is_published=False))
  
          return sorted(branches, key=attrgetter('name'))
docs: Returns a list of local and remote branches.