Reference error during commit
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.
Gitpython version is 2.0.2
Could you provide a script that makes this issue reproducible? Otherwise I am afraid there is no way to fix it. Thank you.
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.
To me it looks like a usability issue that might be worth being looked into.