rm -f .git/index.lock
Such problems generally occur when you execute two git
commands simultaneously; maybe one from the command prompt and one from an IDE.
Use the below command in the root directory of the application. This will delete the index.lock file and release the active lock.
rm .git/index.lock
Deleting my commit message worked for me.
rm .git/COMMIT_EDITMSG
It is similar to above methods but in my case I had several of those
.git/refs/heads/<branch_name>.lock
and was able to remove all at once by this way
find -name "*.lock" -exec xargs rm {} \;
If you are using CocoaPods and at some point botched an update or install (manually killed it or something), try
1) Removing the index.lock
file (in .git/index.lock
)
2) Remove your Podfile.lock
file.
3) Do a new pod update
4) Try issuing the git command that was failing (in my case it was a git add .
)
If you are windows user there will be error 'rm' is not recognized as an internal or external command
. That's because rm is a Linux command. So in windows, you can use below to remove the index.lock
file inside .git
folder
del -f .git/index.lock
rm -f ./.git/index.lock
To fix: