gitpractice.dev

brewly — Ch.6 · Squash your corrections

Exercise 5 of 8

Before you start

Folding commits together

In the todo list, squash melts a commit into the one above it and lets you edit the combined message. fixup does the same but throws the small commit’s message away.

For a correction you are about to commit, git commit --fixup <commit> names its target. --autosquash then puts it in the right place of the list for you.

Move other lines yourself so they sit right below their target.

git add <file>
stage the correction
git commit --fixup <commit>
commit it as a fix for that commit
git rebase -i --autosquash main
edit the list, fixups already placed
git log --oneline
check the result
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