Git Merge
Combine branches with fast-forward or merge commits, and resolve conflicts.
- git merge
- merge conflict
- no-ff
- fast-forward
- merge abort
Git Merge
Combine branches with fast-forward or merge commits, and resolve conflicts.
Commands
| Command | What it does |
|---|---|
git merge <branch> | Merge a branch into the current one |
git merge --no-ff <branch> | Always create a merge commit |
git merge --abort | Cancel a conflicted merge |
git log --graph --oneline --merges | Show merge commits as a graph |
git diff --name-only --diff-filter=U | List files still in conflict |
Example
git switch main
git merge --no-ff feature/search
git log --graph --oneline -8
FAQ
Fast-forward vs merge commit?
Fast-forward moves the pointer when history is linear; --no-ff preserves a merge node so feature history stays visible.
How do I resolve a merge conflict?
Edit the conflicted files, git add them, then git commit to finish the merge.
Câu hỏi thường gặp
Fast-forward vs merge commit?
Fast-forward moves the pointer when history is linear; --no-ff preserves a merge node so feature history stays visible.
How do I resolve a merge conflict?
Edit the conflicted files, git add them, then git commit to finish the merge.
Git
Git Config Essentials
Set identity, defaults, and aliases for Git on a new machine.
Git Clone and Init
Start a repo from scratch or copy a remote repository locally.
Git Add and Commit
Stage changes and record them as commits with clear messages.
Git Branch Basics
Create, list, rename, and delete branches for parallel work.