Merge — Explained with Examples
Merge combines changes from different branches into a single branch, integrating parallel lines of development in a Git repository.
Merging takes the commits from one branch and applies them on top of another. Git supports several types of merges. A fast-forward merge simply moves the target branch pointer forward when there is a linear history. A three-way merge uses two branch tips and their common ancestor to create a new merge commit when branches have diverged.
Think of merging like combining two threads of yarn into one. If the threads are parallel and never crossed, you just tie them end-to-end (fast-forward). If they tangled independently, you need to weave them together at the meeting point (three-way merge).
When Git cannot automatically resolve differences between branches, a merge conflict occurs. Git marks the conflicting areas in the affected files, and you must manually resolve them before completing the merge.
# Switch to the target branch
git checkout main
# Merge feature branch into main
git merge feature/login
# In case of conflict, resolve manually, then:
git add resolved-file.txt
git commit -m "Merge feature/login into main"Merging is fundamental to collaboration. Without it, parallel development would be impossible — every team member would need to work sequentially.
Branch, Rebase, Cherry Pick, Merge Conflict Resolution, Git
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro