Repository: appsmithorg/appsmith
File: app/server/appsmith-git/src/main/java/com/appsmith/git/handler/ce/FSGitHandlerCEImpl.java (Java)

Code before:
                                        MergeResult mergeResult = git.merge()
                                                .include(git.getRepository().findRef(sourceBranch))
                                                .setStrategy(MergeStrategy.RECURSIVE)
                                                .call();
                                        processStopwatch.stopAndLogTimeInMillis();
                                        return mergeResult.getMergeStatus().name();
                                    } catch (GitAPIException e) {
                                        // On merge conflicts abort the merge => git merge --abort
                                        git.getRepository().writeMergeCommitMsg(null);
                                        git.getRepository().writeMergeHeads(null);
                                        processStopwatch.stopAndLogTimeInMillis();
                                        throw new Exception(e);
                                    } finally {
                                        jgitMergeSpan.end();
                                    }
                                })
                                .onErrorResume(error -> {
                                    if (keepWorkingDirChanges) {
                                        return Mono.error(error);
                                    }

                                    try {
                                        return resetToLastCommit(repoSuffix, destinationBranch, keepWorkingDirChanges)
                                                .thenReturn(error.getMessage());
                                    } catch (Exception e) {
                                        log.error("Error while hard resetting to latest commit {0}", e);
                                        return Mono.error(e);
                                    }
                                })
                                .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
                                .name(GitSpan.FS_MERGE)
                                .tap(Micrometer.observation(observationRegistry)),
                        Git::close)
                .subscribeOn(scheduler);
    }

    @Override
    public Mono<String> fetchRemote(
            Path repoSuffix,
            String publicKey,
            String privateKey,
            boolean isRepoPath,
            String branchName,
            boolean isFetchAll) {
        Stopwatch processStopwatch =
                StopwatchHelpers.startStopwatch(repoSuffix, AnalyticsEvents.GIT_FETCH.getEventName());
        Path repoPath = TRUE.equals(isRepoPath) ? repoSuffix : createRepoPath(repoSuffix);
        return Mono.using(
                        () -> Git.open(repoPath.toFile()),
                        git -> Mono.fromCallable(() -> {
                                    Span jgitFetchRemoteSpan = observationHelper.createSpan(GitSpan.JGIT_FETCH_REMOTE);

Review comment (bug):
This is an incorrect format for logging using Slf4j. Please check. I think the correct way would be to do something like this: 

```log.error("Error while hard resetting to latest commit", e);```

Code after:
                                        MergeResult mergeResult = git.merge()
                                                .include(git.getRepository().findRef(sourceBranch))
                                                .setStrategy(MergeStrategy.RECURSIVE)
                                                .call();
                                        processStopwatch.stopAndLogTimeInMillis();
                                        return mergeResult.getMergeStatus().name();
                                    } catch (GitAPIException e) {
                                        // On merge conflicts abort the merge => git merge --abort
                                        git.getRepository().writeMergeCommitMsg(null);
                                        git.getRepository().writeMergeHeads(null);
                                        processStopwatch.stopAndLogTimeInMillis();
                                        throw new Exception(e);
                                    } finally {
                                        jgitMergeSpan.end();
                                    }
                                })
                                .onErrorResume(error -> {
                                    if (keepWorkingDirChanges) {
                                        return Mono.error(error);
                                    }

                                    try {
                                        return resetToLastCommit(repoSuffix, destinationBranch, keepWorkingDirChanges)
                                                .thenReturn(error.getMessage());
                                    } catch (Exception e) {
                                        log.error("Error while hard resetting to latest commit", e);
                                        return Mono.error(e);
                                    }
                                })
                                .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
                                .name(GitSpan.FS_MERGE)
                                .tap(Micrometer.observation(observationRegistry)),
                        Git::close)
                .subscribeOn(scheduler);
    }

    @Override
    public Mono<String> fetchRemote(
            Path repoSuffix,
            String publicKey,
            String privateKey,
            boolean isRepoPath,
            String branchName,
            boolean isFetchAll) {
        Stopwatch processStopwatch =
                StopwatchHelpers.startStopwatch(repoSuffix, AnalyticsEvents.GIT_FETCH.getEventName());
        Path repoPath = TRUE.equals(isRepoPath) ? repoSuffix : createRepoPath(repoSuffix);
        return Mono.using(
                        () -> Git.open(repoPath.toFile()),
                        git -> Mono.fromCallable(() -> {
                                    Span jgitFetchRemoteSpan = observationHelper.createSpan(GitSpan.JGIT_FETCH_REMOTE);