If no other git process is currently running, this probably means a git process crashed in this repository earlier. Make sure no other git process is running and remove the file manually to continue.

What should be the resolution to get rid of this error:

  1. Open terminal & go to the path where your project is.
  2. Type  ls  command and check if there is a .git folder. This is a hidden folder. Make sure you have enabled flag to see hidden files. If not check this blog – How to show hidden files and folders in Mac OS-X-Finder.
  3. Type  cd .git  it will enter into the .git directory.
  4. Type  ls  command to check the files.
  5. You will see there is a file  index.lock
  6. Type  rm -f index.lock  command to delete the file. This will delete the file. Make sure you have the ownership. Otherwise Type  sudo rm -f index.lock Enter password.
  7. Type  cd ..
  8. Type  git commit  to commit again.
Git Notes