From d1a951f5db001b60e0fc92818e6dd0b42689b161 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Tue, 1 Jun 2021 17:02:23 +0200
Subject: [PATCH] fix(git): reset branch to default before fetch

Closes #10261
---
 lib/util/git/index.ts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts
index 1420f18a5c..88dc7e2704 100644
--- a/lib/util/git/index.ts
+++ b/lib/util/git/index.ts
@@ -265,6 +265,7 @@ export async function syncGit(): Promise<void> {
   if (await fs.exists(gitHead)) {
     try {
       await git.raw(['remote', 'set-url', 'origin', config.url]);
+      await resetToBranch(await getDefaultBranch(git));
       const fetchStart = Date.now();
       await git.fetch(['--depth=10']);
       config.currentBranch =
-- 
GitLab