Closed
Description
On attempting to checkout a remote branch:
import git
repo = git.Repo.clone_from('[email protected]:gitpython-developers/GitPython.git', 'delme')
print(repo.remotes)
origin = repo.remotes.origin
print(origin.refs)
# Raises TypeError (but does correctly checkout the ref)...
origin.refs['0.1'].checkout()
The following exception is raised, even though the branch is successfully checkout out:
:> python test.py
[<git.Remote "origin">]
[<git.RemoteReference "refs/remotes/origin/0.1">, <git.RemoteReference "refs/remotes/origin/0.2">, <git.RemoteReference "refs/remotes/origin/HEAD">, <git.RemoteReference "refs/remotes/origin/experiment-2012">, <git.RemoteReference "refs/remotes/origin/fix-ci-tests">, <git.RemoteReference "refs/remotes/origin/fix-non-ascii-chars-in-status-lines">, <git.RemoteReference "refs/remotes/origin/gh-pages">, <git.RemoteReference "refs/remotes/origin/issue-232-reproduction">, <git.RemoteReference "refs/remotes/origin/issue-301-reproduction">, <git.RemoteReference "refs/remotes/origin/master">, <git.RemoteReference "refs/remotes/origin/revert-357-autointerrupt_deadlock_fix">]
Traceback (most recent call last):
File "test.py", line 9, in <module>
origin.refs['0.1'].checkout()
File "/data/local/itwl/miniconda2/envs/sss-core/lib/python2.7/site-packages/git/refs/head.py", line 215, in checkout
return self.repo.active_branch
File "/data/local/itwl/miniconda2/envs/sss-core/lib/python2.7/site-packages/git/repo/base.py", line 670, in active_branch
return self.head.reference
File "/data/local/itwl/miniconda2/envs/sss-core/lib/python2.7/site-packages/git/refs/symbolic.py", line 258, in _get_reference
raise TypeError("%s is a detached symbolic reference as it points to %r" % (self, sha))
TypeError: HEAD is a detached symbolic reference as it points to '90d73cd6ffa6e848da59cb2a35dec74e0fabd00a'
Is this a genuine issue, or is there a different approach I should take to checking out a remote branch?
Many thanks