diff --git a/lib/manager/gomod/artifacts.ts b/lib/manager/gomod/artifacts.ts
index bf905fdfc786bbea36dc1d8dc62922ab9e6342d6..ae27390e95a2509509681bad49ba465f44e013b0 100644
--- a/lib/manager/gomod/artifacts.ts
+++ b/lib/manager/gomod/artifacts.ts
@@ -1,4 +1,5 @@
 import { ensureDir } from 'fs-extra';
+import { quote } from 'shlex';
 import { dirname, join } from 'upath';
 import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms';
 import { logger } from '../../logger';
@@ -16,9 +17,10 @@ function getPreCommands(): string[] | null {
   });
   let preCommands = null;
   if (credentials && credentials.token) {
-    const token = global.appMode
+    let token = global.appMode
       ? `x-access-token:${credentials.token}`
       : credentials.token;
+    token = quote(token);
     preCommands = [
       `git config --global url.\"https://${token}@github.com/\".insteadOf \"https://github.com/\"`, // eslint-disable-line no-useless-escape
     ];