Challenge - 5 Problems
Git Amend Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of amending last commit with new message
What is the output of the following command sequence in a git repository?
git commit --amend -m "Updated commit message"Git
git commit --amend -m "Updated commit message"
Attempts:
2 left
💡 Hint
Amending changes the last commit message or content if staged.
✗ Incorrect
The command replaces the last commit message with the new one if there are no conflicts or errors.
🧠 Conceptual
intermediate1:30remaining
Effect of amending last commit on commit hash
What happens to the commit hash when you amend the last commit in git?
Attempts:
2 left
💡 Hint
Commit hash depends on commit content and metadata.
✗ Incorrect
Amending changes the commit content or metadata, so git creates a new commit with a new hash.
❓ Troubleshoot
advanced2:00remaining
Error when amending last commit with unstaged changes
You run
What is the cause?
git commit --amend but get the error:fatal: no changes added to commit (use "git add" and/or "git commit -a")What is the cause?
Attempts:
2 left
💡 Hint
Amend requires staged changes or message edit.
✗ Incorrect
Git requires changes to be staged to include them in the amended commit; otherwise, it errors.
🔀 Workflow
advanced2:30remaining
Correct workflow to amend last commit with new file added
Which sequence correctly amends the last commit by adding a new file
notes.txt?Attempts:
2 left
💡 Hint
You must stage changes before amending.
✗ Incorrect
First create the file, stage it, then amend the last commit without changing the message.
✅ Best Practice
expert3:00remaining
Best practice when amending a commit already pushed to shared repository
You amended your last commit after pushing it to a shared repository. What is the best practice to avoid problems for others?
Attempts:
2 left
💡 Hint
Rewriting history after pushing can cause conflicts for others.
✗ Incorrect
Amending pushed commits rewrites history and can confuse collaborators; better to add new commits.