Issue with Adding External Project as a Git Submodule “already exists in the index”

When you tried to move part of your code to external repo and later add it back as a git submodule you may see this error:

'lib/my-repo' already exists in the index

Then you can try the following:

git rm -rf 'lib/my-repo'
git submodule add lib/my-repo