diff --git a/x-pack/plugins/code/server/repository_service.ts b/x-pack/plugins/code/server/repository_service.ts index ccf4d4f21dc2a..2abf97bb304a6 100644 --- a/x-pack/plugins/code/server/repository_service.ts +++ b/x-pack/plugins/code/server/repository_service.ts @@ -142,12 +142,12 @@ export class RepositoryService { // TODO(mengwei): deal with the case when the default branch has changed. const currentBranch = await repo.getCurrentBranch(); const currentBranchName = currentBranch.shorthand(); - await repo.mergeBranches( - currentBranchName, - `origin/${currentBranchName}`, - Git.Signature.default(repo), - Git.Merge.PREFERENCE.FASTFORWARD_ONLY - ); + const originBranchName = `origin/${currentBranchName}`; + const originRef = await repo.getReference(originBranchName); + const headRef = await repo.getReference(currentBranchName); + if (!originRef.target().equal(headRef.target())) { + await headRef.setTarget(originRef.target(), 'update'); + } const headCommit = await repo.getHeadCommit(); this.log.debug(`Update repository to revision ${headCommit.sha()}`); return {