0
0
Gitdevops~30 mins

Editing commit messages with rebase in Git - Mini Project: Build & Apply

Choose your learning style9 modes available
Editing commit messages with rebase
📖 Scenario: You have made several commits in your local Git repository. Now, you want to improve the commit messages to make them clearer and more descriptive before sharing your work with your team.
🎯 Goal: Learn how to edit commit messages of previous commits using Git's interactive rebase feature.
📋 What You'll Learn
Have a Git repository with at least three commits
Use Git commands to edit commit messages
Understand how to use interactive rebase safely
💡 Why This Matters
🌍 Real World
Improving commit messages helps your team understand changes clearly and keeps project history clean.
💼 Career
Editing commit messages is a common task for developers and DevOps engineers to maintain professional and readable version control history.
Progress0 / 4 steps
1
Create three commits with specific messages
Create three commits in your Git repository with these exact commit messages in order: Initial commit, Add README file, and Fix typo in README. Use git commit -m to set the messages.
Git
Need a hint?

Use git commit -m "message" to create commits with the exact messages.

2
Start interactive rebase to edit commit messages
Run the Git command to start an interactive rebase for the last three commits using git rebase -i HEAD~3.
Git
Need a hint?

Use git rebase -i HEAD~3 to start editing the last three commits.

3
Change commit messages to new ones in the rebase editor
In the interactive rebase editor, change the word pick to reword for all three commits to edit their messages. Save and close the editor to proceed.
Git
Need a hint?

Change pick to reword for each commit line in the editor to edit messages.

4
Edit commit messages and verify final log
For each commit message prompt during the rebase, change the messages to these exact new messages in order: Setup project files, Add project README, and Correct README typo. After finishing, run git log --oneline and print the output.
Git
Need a hint?

When prompted, replace each commit message with the new exact message. Then run git log --oneline to see the updated commits.