Git Submodule Reset Alias

Posted on Jun 27, 2023

If you have ever worked with git submodules, you know that they have the tendency to get into bad states. Especially if changing branches with differing submodule pointers and or changing the name of the submodule between branches. I would like to introduce a git alias that I used as a get out of jail free card when submodules inevitably get in a bad state.

git config --global alias.smr "!git submodule deinit -f . && git submodule update –init --recursive"

This can be run by git gmr and stands for submodule reset but you can rename it to suit your needs. Hope this helps 🙂.