Video in progress

Strong Junior 🌿 Git

How do you resolve the conflict below? How do you find out what changed on each side?

<<<<<<< HEAD
    @Bean
    RestClient paymentClient() {
        return builder.requestFactory(factory(Duration.ofSeconds(10))).build();
    }
=======
    @Bean
    RestClient paymentClient() {
        return builder.requestFactory(factory(Duration.ofSeconds(3)))
                .requestInterceptor(new RetryInterceptor(3)).build();
    }
>>>>>>> feature/payment-retry

The HEAD part is your current branch, and the bottom part is the branch being merged in. Both changes are needed here: one raised the timeout and the other added retry, so you write them combined.

📖 Answer

The first step is to understand what each side changed it for, not to hit "keep mine". For that:

git log --merge -p -- src/main/java/.../PaymentConfig.java

This shows the commits on both sides that caused the conflict. Say that on main the timeout was deliberately raised to 10 seconds (the payment provider responds slowly), and in the feature, retry was added.

The right result keeps both:

@Bean
RestClient paymentClient() {
    return builder.requestFactory(factory(Duration.ofSeconds(10)))
            .requestInterceptor(new RetryInterceptor(3)).build();
}

Then check that no markers are left, run the tests, git add, and finish the merge.

A helper: git config --global merge.conflictstyle zdiff3 also shows the original (common ancestor) version in the conflict. That makes it much clearer who changed what.