Git index lock error

Have you ever had an error with git? Well a common error I have encountered is having a “.git/index.lock’: File exists”. This error will make it so you cannot pull or push from your repository, leaving you stranded. I have found a solution.

  1. Navigate to the top level directory for your repo
  2. cd .git
  3. rm -f index.lock
  4. cd ..
  5. cd add .
  6. cd commit -m “your message”
  7. cd push

This will get rid of the lock and reopen the flow of git and allow you to pull from your github repos.