gitpractice.dev

brewly — Ch.5 · Clean up after a squash merge

Exercise 6 of 6

Before you start

A squash merge makes a new commit

Squashing puts one new commit on main. Your original commits are never merged, only their changes.

This team’s server deletes the branch after merging. git fetch --prune removes your outdated origin/… name for it.

git branch -d then refuses to delete your local branch, because its commits are not on main. You know the work arrived, so -D deletes it anyway. Be sure before you use it.

git switch main
leave the finished branch
git pull
get the squashed commit
git fetch --prune
forget branches deleted on the server
git branch -d <name>
delete, only if merged
git branch -D <name>
delete even if git sees it 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