Interactive Rebase: Squash, Edit & Reorder Commits
Intermediate · 30 minutes · 100 points
Master Git's powerful interactive rebase tool to clean up messy commit histories. In this lab you will create a repository with multiple commits, then use 'git rebase -i' to squash related commits together, edit commit messages, and reorder commits to produce a clean, professional history before merging.
What you’ll learn
- Initialise a Git repository and build a realistic messy commit history with multiple work-in-progress commits
- Use 'git rebase -i' with the 'squash' (s) directive to combine related WIP commits into a single meaningful commit
- Use 'git rebase -i' with the 'reword' (r) directive to fix a poorly written commit message
- Use 'git rebase -i' to reorder commits so the history tells a logical story
- Verify the final cleaned-up history is correct and all file content is intact
How this lab works
- Start the lab: One click starts a container on your computer with a real terminal: nothing to install by hand, nothing to clean up.
- Work through 5 tasks: Each task says what to build or fix. You do it yourself, in a real terminal, with hints when you get stuck.
- Check your work: Check my work runs each task’s checks in your container and says what passed and what to fix.
- Finish and keep going: 100 points, your progress saved, and the next lab to try.
What it runs on
- Runs: A container on your computer, with a real terminal
- Image: ubuntu:22.04
What you need
- A free LearnXops account
- The LearnXops desktop app for macOS, Windows or Linux
- Docker Desktop installed and running
Topics: git, rebase, interactive-rebase, squash, commit-history, version-control, clean-history, reword
Create a free account to start this lab.