A developer has committed several files but forgot to include a small configuration file in the last commit. They have NOT yet pushed to the remote. Which Git command lets them add the forgotten file to the most recent commit WITHOUT creating a new commit?
- A.
git reset --hard HEAD~1 - B.
git cherry-pick HEAD - C.
git commit --amend✓ Correct - D.
git revert HEAD
Explanation
git commit --amend rewrites the most recent commit, allowing the developer to stage new changes and include them in the existing commit without creating an additional commit. git revert HEAD creates a new commit that undoes the previous commit—it does not modify the original. git reset --hard HEAD~1 removes the last commit entirely and discards all changes, which is destructive and not appropriate here. git cherry-pick HEAD applies the changes from a specific commit onto the current branch; it doesn't amend an existing commit.