A Three-Day-Old index.lock File from Git
In all my years of working with Git, this seems to be the first time I’ve run into this error. It’s trivial, but I’ll document it in my dev log anyway.
This morning, I couldn’t run git pull:
error: Unable to create ‘[REDACTED]/.git/index.lock’: File exists.
Another Git process seems to be running in this repository, or the lock file may be stale
The typical “someone else is working on your repository” message. Is it a cron job, an IDE, or did I leave a terminal open somewhere? You can check it like this
$ ps aux | grep [g]it # no active git processes
$ ls -la .git/index.lock # -rw-r--r-- 1 rinat users 0 Aug 28 19:01
$ date # Mon Aug 31 09:09
A three-day-old abandoned lock. That means I can “fix” it by editing the file directly
$ rm .git/index.lock
$ git pull