Sometimes when I try and run git fetch I get the following response:
error: cannot lock ref 'refs/remotes/origin/branchname': is at XXXXXX but expected YYYYYY
The steps that I took that caused this were, to the best of my recollection, the following:
- I did a
git pushfrom my work-PC, as I usually do, to the origin hosted at Bitbucket; - I did an uncommon
git fetchwhen I got home. There were no errors or warnings; - I did an uncommon
git pushafter working at home. There were no errors or warnings; - I did a
git fetchwhen I arrived at the work today.
Step 4 caused the error message. My local repository had the offending branch checked out. Still I just ran git pull and it seemed to work.
This is not the first time I saw this error message. The first time it happened, I fetched another team's repository to update my local copy which had been sitting untouched (no fetching, no work, no pushing) for one month or two. When I pushed my changes, my co-worker got the error.
So in the two cases it seems to be somewhat related to local repositories which stay untouched for a while. But a sample of two is quite small to draw any conclusions.
I'd like to know what could be causing this. And, more importantly, if it is indeed harmless or if I'm at risk of losing work.