Introduction
Welcome, time-traveling Git explorer! You've been tasked with an important mission: to clean up the messy commit history of a top-secret project. Your goal is to use your newly acquired Git powers, specifically the art of interactive rebasing, to transform a chaotic timeline into a clear, concise history.
Imagine you're a historian with the ability to rewrite the past. Your job is to take a series of scattered events and reorganize them into a coherent narrative. That's exactly what you'll be doing with Git's interactive rebase feature. You'll combine related commits, remove unnecessary ones, and rewrite commit messages to tell a clearer story of your project's development.
Are you ready to dive into the timestream and emerge with a polished Git history? Let's begin your temporal adventure!
Cleaning Up the Timeline
Tasks
The challenge repo has been set up in ~/project/time-travel-git. Run the following command to view the initial commit history:
cd ~/project/time-travel-git
git log --oneline
You should see the following 4 commits (your commit hashes will be different):
886c6ad (HEAD -> master) Add project description
3a87b84 Add project codename
6b4cbb9 Fix typo in project name
0d71e5e Start secret project
Your mission involves the following tasks:
- Combine the oldest two commits ("Start secret project" and "Fix typo in project name") into a single commit with the message "Initialize secret project".
- Reword the "Add project codename" commit to "Add project codename: Chronos".
- Keep the newest commit ("Add project description") as is.
Requirements
To successfully complete this mission, adhere to the following requirements:
- All operations must be performed in the
~/project/time-travel-gitdirectory. - You must use the
git rebase -i(interactive rebase) command to clean up the commit history. - Your final history should have exactly 3 commits (instead of the original 4).
- The content of the file should remain unchanged - you're only modifying the commit history.
- When the challenge is complete, running
git log --onelineshould show 3 commits with the correct messages.
Hints
Here are some helpful hints to guide you through the challenge:
Interactive rebase allows you to manipulate commits in your history. The basic command format is:
git rebase -i <commit>where
<commit>is the commit before the first one you want to modify. To modify from the very first commit, you can use:git rebase -i --rootIn the interactive rebase screen, you'll see a list of commits with actions. The common actions are:
pick- use the commit as isrewordorr- use the commit but change its messagesquashors- combine this commit with the previous onefixuporf- like squash, but discard this commit's message
To combine commits, you might want to use either
squashorfixupon the second commit.To change a commit message, use the
rewordaction.After setting up your rebase plan, save and close the editor. Git will guide you through the rest of the process, opening new editor windows as needed for editing commit messages.
If you make a mistake during the rebase, you can always abort it with:
git rebase --abortand start over.
Example
After completing the challenge, your git log --oneline should look similar to this (with different commit hashes):
abc1234 Add project description
def5678 Add project codename: Chronos
ghi9101 Initialize secret project
Summary
In this challenge, you've embarked on a time-bending journey through Git's history. You've mastered the art of interactive rebasing, a powerful tool that allows you to reshape the past and create a cleaner, more logical commit history.
By combining commits, rewording messages, and reorganizing changes, you've transformed a messy sequence of events into a coherent narrative. This skill is invaluable in real-world projects, where maintaining a clean and understandable history can greatly improve collaboration and project management.
Remember, with great power comes great responsibility. While rewriting history can be useful for local branches or personal projects, it should be used cautiously on shared branches. Always communicate with your team before modifying shared history.
As you continue your Git adventures, keep honing these skills. The ability to manipulate history isn't just about tidying up—it's about crafting a clear story of your project's evolution. May your future Git histories be clean, your merges conflict-free, and your commits always meaningful!



