You have to swap the git rm --cached $path_to_submodule and git add .git modules no? I did get an error on the first command: fatal: Please stage your changes to .git modules or stash them to proceed because I had upstaged changes to .git modules. Doing the git add .git modules first solves that.