gitpractice.dev

brewly — Ch.6 · Rewrite your own history

Exercise 4 of 8

Before you start

The interactive rebase

git rebase -i <commit> opens a todo list of the commits after that one, oldest first. Git then does what the list says, from top to bottom.

Change the word at the start of a line: pick keeps a commit, reword lets you change its message. Moving a line moves the commit.

Save the list. For each reworded commit another editor opens with its message.

git log --oneline
see your commits
git rebase -i main
edit the commits that are not on main
git rebase --abort
return to how it was
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