diff --git a/src/git-auth-helper.ts b/src/git-auth-helper.ts
index 8a1c7c3..888fde1 100644
--- a/src/git-auth-helper.ts
+++ b/src/git-auth-helper.ts
@@ -363,10 +363,12 @@ class GitAuthHelper {
       }
     }
 
-    const pattern = regexpHelper.escape(configKey)
-    await this.git.submoduleForeach(
-      `git config --local --name-only --get-regexp '${pattern}' && git config --local --unset-all '${configKey}' || :`,
-      true
+    if (this.settings.submodules) {
+      const pattern = regexpHelper.escape(configKey)
+      await this.git.submoduleForeach(
+        `git config --local --name-only --get-regexp '${pattern}' && git config --local --unset-all '${configKey}' || :`,
+        true
+      )
     )
   }
 }