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

CommandWhat it does
git merge <branch>Merge a branch into the current one
git merge --no-ff <branch>Always create a merge commit
git merge --abortCancel a conflicted merge
git log --graph --oneline --mergesShow merge commits as a graph
git diff --name-only --diff-filter=UList 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.

Întrebări frecvente

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