today-i-learnt

How to reset submodules in git repo

Category git
Added on 2026-03-18
Source source

De-initialise all submodules then checkout them again (contextual to update)

$ git submodule deinit -f .
$ git submodule update --init

If your sub-modules have their own sub-modules, instead of second command, try:

$ git submodule update –init –recursive –checkout


Last if you have edits in submodules you may get `error: Your local changes to the following files would be overwritten by checkout`. 

You can either update specific other submodules with

$ git submodule deinit -f – and then $ git submodule update --init -- ```

or need to investigate and revert the changes.