I\'m trying to learn how to use Git and have created a small project with an HTML, CSS, and Javascript file. I made a branch from my basically empty project and then made so
Try deleting index.lock file in your .git directory.
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.
This happened to me and while sourcetree kept telling me the lock file exists, there was no such a file there for me to remove. So I just checked out another branch and then returned to the original branch and noticed this change fixed the issue.
Solved it by going into the .git folder and manually deleting the HEAD.lock file
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 .)