Reputation: 2888
I have a large git repo in which occasionally a git process crashes and left the index lock file, which needs to be remove manually
rm -f ./.git/index.lock
Is there a way to safely remove git index lock with an automatic cron job, by checking if there's no other git processes running?
Upvotes: 1
Views: 2777
Reputation: 488183
Don't automate that: if you do, you'll find it strikes just as you're trying to, say, make a commit, and removes your new index.1 (The index.lock
file is used not only to lock the current index, but also to provide the new index that will replace the old one after any operation that causes the index to need updating.)
As CryptoFool said in a comment, it's best to fix the original problem, whatever it may be. Often that just means "upgrade your Git version".
1You said you'd "check that there is no Git process running", but this kind of checking is inherently racy. Things always go wrong here (Murphy's laws).
Upvotes: 4