diff --git a/lib/util/git/private-key.ts b/lib/util/git/private-key.ts
index 3c2b9a5a46cd26debabbd919c680cc72c3f46026..06a15b407c4df415ff315a3b795a72c155e320e5 100644
--- a/lib/util/git/private-key.ts
+++ b/lib/util/git/private-key.ts
@@ -1,4 +1,5 @@
 import os from 'os';
+import is from '@sindresorhus/is';
 import fs from 'fs-extra';
 import upath from 'upath';
 import { PLATFORM_GPG_FAILED } from '../../constants/error-messages';
@@ -10,7 +11,13 @@ let gitPrivateKey: string | undefined;
 let keyId: string | undefined;
 
 export function setPrivateKey(key: string | undefined): void {
-  gitPrivateKey = key?.trim();
+  if (!is.nonEmptyStringAndNotWhitespace(key)) {
+    return;
+  }
+  logger.debug(
+    'gitPrivateKey: successfully set (but not yet written/configured)'
+  );
+  gitPrivateKey = key.trim();
 }
 
 async function importKey(): Promise<void> {
@@ -34,11 +41,11 @@ export async function writePrivateKey(): Promise<void> {
   if (!gitPrivateKey) {
     return;
   }
-  logger.debug('Setting git private key');
   try {
     await importKey();
+    logger.debug('gitPrivateKey: imported');
   } catch (err) {
-    logger.warn({ err }, 'Error writing git private key');
+    logger.warn({ err }, 'gitPrivateKey: error importing');
     throw new Error(PLATFORM_GPG_FAILED);
   }
 }
@@ -47,7 +54,7 @@ export async function configSigningKey(cwd: string): Promise<void> {
   if (!gitPrivateKey) {
     return;
   }
-  logger.debug('Configuring commits signing');
+  logger.debug('gitPrivateKey: configuring commit signing');
   // TODO: types (#7154)
   await exec(`git config user.signingkey ${keyId!}`, { cwd });
   await exec(`git config commit.gpgsign true`, { cwd });