01 · What is it?
Merge combines changes from one Git branch into another branch.
It brings the work from a source branch into a target branch so the target branch contains both lines of work.
The source branch contributes changes; the target branch receives them.
02 · Think of it like...
Think of a merge like combining two versions of a document.
One person works on a copy while another person continues the main document. When the copy is ready, the changes are brought into the main document.
Feature Branch
→
Merge
→
Main Branch
03 · What does it do?
A merge brings related development work together and records the result in the target branch.
Combine ChangesBring work from one branch into another branch.
Update the TargetAdd the source branch’s changes to the target branch.
Preserve the HistoryKeep the branch and commit history that explains how the work came together.
Reveal ConflictsStop for a decision when Git cannot safely combine overlapping edits.
04 · Where is it used?
Teams use merges whenever work developed in parallel needs to become part of another branch.
Feature WorkBring in a featureMerge a completed feature branch into the branch used for integration.
Pull RequestsAccept reviewed workMerge an approved pull request into its target branch.
Release PreparationCollect tested changesMerge selected work into a release branch before deployment.
Team CollaborationCombine parallel workBring work from different contributors into a shared line of development.
05 · Example
A team has a main branch and a checkout-tax branch.
| Branch | Work |
|---|
| main | Current shared application |
| checkout-tax | Tax calculation changes |
The team reviews the tax changes, then combines them into main.
The target branch is checked out before the merge:
git switch main
git merge checkout-tax
After the merge, main contains the earlier main work and the checkout-tax work.
06 · How it connects
Working Branch
→
Commit
→
Pull Request
→
Code Review
→
Merge
→
Target Branch
A merge is the step that brings reviewed branch work into the branch that should contain it.
07 · Do Not Confuse
Merge
Combines the changes from one branch into another branch.
Commit
Records a set of changes in the repository history.
Pull Request
Proposes that branch changes be reviewed and merged.
Rebase
Replays commits onto a different starting point; it is another way to reorganize branch history.
A pull request asks for a merge; the merge performs the branch integration.
08 · Topic Glossary
| ENGLISH TERM | 中文 | SIMPLE ENGLISH | 中文小白理解 |
| Merge | 合并 | Combining changes from one branch into another branch. | 把一个分支的修改合并到另一个分支。 |
| Branch | 分支 | A separate line of work in a Git repository. | 代码仓库里一条独立的开发线路。 |
| Source Branch | 源分支 | The branch whose changes are being brought into another branch. | 要把修改带到别的分支里的分支。 |
| Target Branch | 目标分支 | The branch that receives the merged changes. | 接收合并后修改的分支。 |
| Commit | 提交 | A saved set of changes in Git history. | Git 历史中保存下来的一组修改。 |
| Conflict | 冲突 | A situation where Git cannot combine overlapping changes automatically. | 不同修改重叠,Git 无法自动决定保留哪一个。 |
| Fast-forward | 快进 | A merge where the target branch can move directly to the source branch’s latest commit. | 目标分支可以直接移动到源分支最新提交的合并方式。 |
| Pull Request | 拉取请求 | A request for people to review and integrate branch changes. | 请别人评审并把分支修改合并进去的请求。 |
09 · What to Remember
Merge combines changes from one Git branch into another branch.
The source branch provides the changes, and the target branch receives them.
A merge may be automatic, or it may require resolving a conflict.