From 63f8371b93c74cf8a61e76de1b281e10b8ac57b9 Mon Sep 17 00:00:00 2001
From: Oleg Krivtsov <olegkrivtsov@gmail.com>
Date: Tue, 25 Jan 2022 15:50:30 +0700
Subject: [PATCH] refactor(git): remove first git checkout as redundant
 (#13509)

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
---
 lib/util/git/index.spec.ts | 6 ++++++
 lib/util/git/index.ts      | 1 -
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/util/git/index.spec.ts b/lib/util/git/index.spec.ts
index de9da6eaa1..63cd732cf2 100644
--- a/lib/util/git/index.spec.ts
+++ b/lib/util/git/index.spec.ts
@@ -225,6 +225,12 @@ 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 2b3df13326..3358b96e60 100644
--- a/lib/util/git/index.ts
+++ b/lib/util/git/index.ts
@@ -653,7 +653,6 @@ 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