Skip to content

Reference error during commit #665

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
kai-kzh opened this issue Aug 25, 2017 · 4 comments
Open

Reference error during commit #665

kai-kzh opened this issue Aug 25, 2017 · 4 comments

Comments

@kai-kzh
Copy link

kai-kzh commented Aug 25, 2017

I am seeing following error during repo.index.commit.

OSError: Reference at 'refs/heads/master' does already exist, pointing to u'f746fc427841706fd2ba4302b99c7ae6eb135ab8', requested was 'f428c16e68aa324f24e222269c95f5c24a38db43'

After this error, file has been committed to this repository, if I do a git clone, I can see updated file. But git log will not show this update.

This is a repository only contains one text file which is around 500k. This is not always happen.

I am wondering what is this log indicating and how to prevent it.
Thanks for your attention.

@kai-kzh
Copy link
Author

kai-kzh commented Aug 28, 2017

Gitpython version is 2.0.2

@Byron
Copy link
Member

Byron commented Sep 28, 2017

Could you provide a script that makes this issue reproducible? Otherwise I am afraid there is no way to fix it. Thank you.

@eggonzal
Copy link

I got that error when trying to create a local branch or head using a remote reference, while the head already existed in my local repo and my local repo was pointing to a past commit. To solve it I just checked if the branch already existed in the repo.heads like

def _create_head_master_from_origin(self):
        if not 'master' in self.repo.heads:
            self.logger.debug("Creating local master branch")
            self.repo.create_head('master', self.origin.refs.master)
        self.repo.heads.master.set_tracking_branch(self.origin.refs.master)

If it already existed just switched to that head and updated it with a pull.

@Byron
Copy link
Member

Byron commented Jul 15, 2018

To me it looks like a usability issue that might be worth being looked into.

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