Skip to content

GitPython reports no remote 'origin' #910

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

Closed
adrianbn opened this issue Aug 20, 2019 · 5 comments
Closed

GitPython reports no remote 'origin' #910

adrianbn opened this issue Aug 20, 2019 · 5 comments

Comments

@adrianbn
Copy link

Hi,

I've been seeing the following error pop up every now and then. GitPython 3.0.0 fails to identify the remote origin even though it is there.

>>> from os import system
>>> system('git remote')
origin
0
>>> from git import Repo
>>> repo = Repo('.')
>>> repo.remotes
[]

The stacktrace shows the following:

  File "/usr/local/lib/python3.6/site-packages/git/util.py", line 889, in __getattr__
    return list.__getattribute__(self, attr)
AttributeError: 'IterableList' object has no attribute 'origin'

I don't exactly know why this happens. But a few of our repositories get into this state on occasion. We're running on Python 3.6 @ CentOS 7.

Thanks!

@Byron
Copy link
Member

Byron commented Aug 22, 2019

Thanks for posting! I am tentatively acknowledging the issue based on the assumption that certain git repositories store their references in a format GitPython cannot yet parse.

In order to fix the issue, one would have to provide an example making the issue reproducible. Usually refs are stored in the .git folder, and one should find them wherever they are with grep -r origin .git/, which yields this on my system.

.git//config:[remote "origin"]
.git//config:   fetch = +refs/heads/*:refs/remotes/origin/*
.git//config:   remote = origin
.git//info/refs:4dece994f099bad28f12714698088b81835c24bf        refs/remotes/origin/master
.git//packed-refs:4dece994f099bad28f12714698088b81835c24bf refs/remotes/origin/master

I suspect the packed-refs file to be in a format that is not understood.

@adrianbn
Copy link
Author

Hey @Byron,

a fresh clone of the repositories in question fixed the issue so I can't get you a packed-refs file at the moment. If / when this surfaces again I will be happy to upload one.

@panterozo
Copy link

Hi @Byron .. I followed your suggestions. My project is as follow:

$ grep -r origin .git
.git/refs/remotes/origin/HEAD:ref: refs/remotes/origin/master
.git/config:[remote "origin"]
.git/config:    fetch = +refs/heads/*:refs/remotes/origin/*
.git/config:    remote = origin
.git/config:    remote = origin
.git/packed-refs:510b2bcc03c4b33ee976001fc347e48c50fc953c refs/remotes/origin/Desarrollo-CI
.git/packed-refs:2e2fdce01e7d1809ec20de7ecef2f1327eef3493 refs/remotes/origin/master
.git/packed-refs:e7cad3b1378790fe20c2ac9c1fb22e3c66f81e18 refs/remotes/origin/monitoreo
.git/packed-refs:1869a38e0b7495586067f2fa65d50f6dd6f03f93 refs/remotes/origin/refactor

I commented the problem before in another issue readme. Is the same issue, and my project isn't working yet

Regards

@Byron
Copy link
Member

Byron commented Apr 11, 2020

Thanks, @panterozo .
Could you tell me how the first line of .git/packed-refs look like?
Mine is # pack-refs with: peeled fully-peeled sorted for example. Maybe there is something unusual that prevents GitPython to parse the file.

@Byron
Copy link
Member

Byron commented Jan 6, 2021

As part of spring cleaning, I am closing this issue as it was opened more than half a year ago while still asking for feedback.

If this is a mistake or any other action should rather be taken, please let me know in the comments or create a new issue as digest of this one.
Thanks for your understanding and the work that undoubtedly went into this.

@Byron Byron closed this as completed Jan 6, 2021
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