Managing a Git merge conflict means locating the files Git couldn't automatically reconcile, manually choosing or combining the correct content, and then marking those files as resolved before continuing the operation.
Key Points: • git status lists which files have unresolved conflicts after a merge, rebase, or cherry-pick stops. • Conflicting sections are marked with <<<<<<<, =======, and >>>>>>> markers showing your version versus the incoming version. • Edit the file to keep the correct content and remove the markers entirely; a merge tool can make this easier for complex conflicts. • Run git add on each resolved file to tell Git the conflict is fixed and stage it for the resulting commit. • Finish the operation with git commit (for a merge) or git rebase --continue (for a rebase), or abort with git merge --abort if it's unsalvageable.
Example: After git merge feature-branch reports a conflict in PaymentService.java, the developer opens the file, sees the conflict markers, keeps the correct logic from both sides, removes the markers, then runs git add PaymentService.java and git commit to finish the merge.
Code Example:
<<<<<<< HEAD
int timeout = 30;
=======
int timeout = 60;
>>>>>>> feature-branchInterview Tip: A concise interview answer is:
"I find the conflicting files with git status, edit them to resolve the sections marked with the conflict markers, then stage them with git add. Once every conflict is resolved, I finish the merge or rebase with commit or rebase --continue."