Once work on a branch is finished and tested, merging brings those changes back into another branch — usually main.


Performing a merge

Switch to the branch you want to merge into, then run the merge command pointing at the branch you want to bring in. Git combines the histories automatically whenever possible.

What causes conflicts

A conflict happens when two branches changed the exact same lines of a file in different ways. Git can't decide which version is correct, so it pauses and asks you to choose.

Resolving a conflict

Git marks the conflicting sections directly inside the file. You edit the file to keep the correct content, remove the conflict markers, then stage and commit the result to finish the merge.

>_ COMMANDS YOU'LL USE
git checkout mainSwitch to the branch you want to merge into
git merge feature/loginMerge the feature branch into the current branch
git statusSee which files have conflicts that need resolving
git add resolved-file.txtMark a conflict as resolved after editing the file
git commitComplete the merge after all conflicts are resolved
💡Conflicts are normal, not failures. Read both versions carefully and keep the intent of each change.
⚠️Common mistake: Panicking at merge conflicts