gitpractice.dev

brewly — Ch.6 · Choose how to merge

Exercise 7 of 8

Before you start

Three ways in

Fast-forward: main just moves up. --ff-only allows nothing else and fails if a merge would be needed.

Merge commit: --no-ff records one even when main could just move, so the branch stays visible.

Squash: --squash stages all the branch’s changes at once without recording a merge. You commit them yourself as one commit. The branch is then not "merged", so deleting it needs -D.

git merge --ff-only <branch>
only move forward
git merge --no-ff <branch>
always make a merge commit
git merge --squash <branch>
stage the changes as one
git commit -m "What you did"
commit the squashed changes
git branch -D <name>
delete a branch git sees as unmerged
You can reopen this any time with “Lesson”.

Continue on a desktop

Typing git on a small screen is no fun. Open this page on a laptop or desktop to practise.

Back to the path