Challenge - 5 Problems
Rebase Message Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
Output of interactive rebase command
You run the command
git rebase -i HEAD~3 to edit the last 3 commits. What will Git open for you?Attempts:
2 left
💡 Hint
Think about what interactive rebase is used for.
✗ Incorrect
The command
git rebase -i HEAD~3 opens an editor with the last 3 commits listed. You can choose to edit commit messages, reorder commits, squash commits, or drop commits.🔀 Workflow
intermediate2:00remaining
Steps to change a commit message in the middle of history
You want to change the commit message of the second last commit in your branch. Which sequence of commands correctly achieves this?
Attempts:
2 left
💡 Hint
Amending only works on the latest commit.
✗ Incorrect
To change a commit message in the middle of history, you use interactive rebase and mark the commit with 'reword' to edit its message.
❓ Troubleshoot
advanced2:00remaining
Error during rebase when editing commit message
You run
git rebase -i HEAD~4 and change a commit message, but Git stops with the error: error: could not apply . What is the most likely cause?Attempts:
2 left
💡 Hint
Think about what happens when commits change history.
✗ Incorrect
During rebase, if changes conflict with later commits, Git pauses and asks you to resolve conflicts before continuing.
🧠 Conceptual
advanced1:30remaining
Effect of rebase on commit hashes after editing messages
After editing a commit message using interactive rebase, what happens to the commit hash of that commit and its descendants?
Attempts:
2 left
💡 Hint
Commit hashes are based on the commit content including the message.
✗ Incorrect
Changing a commit message changes the commit content, so its hash changes. This causes all descendant commits to get new hashes as well.
✅ Best Practice
expert2:30remaining
Best practice when rewriting commit messages on a shared branch
You need to rewrite commit messages on a branch that others have already pulled. What is the best practice to avoid problems?
Attempts:
2 left
💡 Hint
Think about collaboration and safety when rewriting history.
✗ Incorrect
Rewriting history on shared branches can cause problems. Informing the team and using
--force-with-lease helps avoid overwriting others' work.