def __verify(self, repository, branch=None):
        """Verify that the specific git branch and the remote repositories exist"""

        cmd = 'git ls-remote --exit-code --heads {0}'.format(repository)
        if branch is not None: cmd = 'git ls-remote --exit-code {0} | grep "{1}"'.format(repository, branch)

        p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE)
        stdout,stderr = p.communicate()

        if p.returncode != 0:
            return 'git repository "{}" or branch "{}" do not exist\n  cmd: "{}"\n  stdout: "{}"\n  stderr: "{}"'.format(
                repository, branch, cmd, stdout, stderr
            )

        return None
Verify that the specific git branch and the remote repositories exist
hpccm/templates/git.py