`$ git checkout -- .gitmodules` is perhaps better here, since it will definitely restore to the original, in case .gitmodules is updated but the other files were forgotten. In that case .relative_submodules is not needed.

(While I'm here, there's a typo on line 103: upate -> update)

Thanks