From 35f0968c32fbdea135efd487054c9f4ca4b00304 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Wed, 26 Jan 2022 12:17:30 +0100
Subject: [PATCH] fix: Revert "refactor(git): remove first git checkout as
 redundant (#13509)" (#13829)

This reverts commit 63f8371b93c74cf8a61e76de1b281e10b8ac57b9.
---
 lib/util/git/index.spec.ts | 6 ------
 lib/util/git/index.ts      | 1 +
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/lib/util/git/index.spec.ts b/lib/util/git/index.spec.ts
index 63cd732cf2..de9da6eaa1 100644
--- a/lib/util/git/index.spec.ts
+++ b/lib/util/git/index.spec.ts
@@ -225,12 +225,6 @@ describe('util/git/index', () => {
 
   describe('mergeBranch(branchName)', () => {
     it('should perform a branch merge', async () => {
-      const repo = Git(GlobalConfig.get('localDir'));
-      await repo.checkout([
-        '-B',
-        'renovate/future_branch',
-        'origin/renovate/future_branch',
-      ]);
       await git.mergeBranch('renovate/future_branch');
       const merged = await Git(origin.path).branch([
         '--verbose',
diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts
index 43ff10a7c3..8ead253350 100644
--- a/lib/util/git/index.ts
+++ b/lib/util/git/index.ts
@@ -610,6 +610,7 @@ export async function mergeBranch(branchName: string): Promise<void> {
   try {
     await syncGit();
     await git.reset(ResetMode.HARD);
+    await git.checkout(['-B', branchName, 'origin/' + branchName]);
     await git.checkout([
       '-B',
       config.currentBranch,
-- 
GitLab