Skip to content

repositories that are not in a detached state are recognized as detached #800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Farom opened this issue Sep 28, 2018 · 2 comments
Open

Comments

@Farom
Copy link
Contributor

Farom commented Sep 28, 2018

user@host:~/src$ git clone https://github.com/gitpython-developers/GitPython.git 
Cloning into 'GitPython'...
remote: Enumerating objects: 14646, done.
remote: Total 14646 (delta 0), reused 0 (delta 0), pack-reused 14646
Receiving objects: 100% (14646/14646), 7.65 MiB | 4.21 MiB/s, done.
Resolving deltas: 100% (9125/9125), done.
user@host:~/src$ cd GitPython/
user@host:~/src/GitPython$ ipython3 
Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
Type "copyright", "credits" or "license" for more information.

In [1]: import git
In [2]: repo = git.Repo()
In [3]: repo.active_branch
Out[3]: <git.Head "refs/heads/master">

In [4]: repo.active_branch.is_detached
Out[4]: True

Do I miss something here? I do not think that this freshly cloned repository is in a detached state.

@Byron
Copy link
Member

Byron commented Oct 14, 2018

Thanks for pointing this out! I was able to reproduce it, too, and do wonder how that could break knowing there is quite some test coverage.

@Mistawes
Copy link

Mistawes commented Nov 3, 2021

What fixed this issue for me, was setting the following on a Jenkins job config (in the checkout section):

Check out to matching local branch

Tried another build and it completed successfully after a day of scratching my head. The detached error wasn't appearing locally, so that's what made me suspect the Jenkins checkout settings.

I'd also re-created the repo and only had one commit, so the detached error didn't seem to make any sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants