This is the script to get the current branch name in git using ssh key
URL = raw_input('Enter the ssh git URL: ')
print URL
from pygit2 import Repository
repo = Repository(URL)
# option 1
head = repo.head
print("Head is " + head.name)
# option 2
head = repo.lookup_reference('HEAD').resolve()
print("Head is " + head.name)
Error:It is showing repository not found.Please help to get the current branch name in git repository
Traceback (most recent call last):
File "Clone.py", line 28, in <module>
Repository(URL).head.shorthand
File "/usr/lib/python2.7/dist-packages/pygit2/repository.py", line 1184, in __init__
path_backend = init_file_backend(path)
_pygit2.GitError: Repository not found at git@gitlab.com:Manoj.ck/sampleproject.git