CS FundamentalsHardGATE CS · TCS NQT Prime · Product Company SDE

What does `git commit --amend` do?

  1. A. Creates a brand-new commit on top, leaving the previous one untouched
  2. B. Replaces the most recent commit with a new one that includes any newly staged changes and/or an edited commit message, effectively rewriting that last commit
  3. C. Permanently deletes the most recent commit with no replacement
  4. D. Pushes the amended commit automatically to the remote

Correct answer: B. Replaces the most recent commit with a new one that includes any newly staged changes and/or an edited commit message, effectively rewriting that last commit

Amend folds currently staged changes (and/or a new message) into the tip commit by replacing it with a new commit object; because this changes the commit's hash, it should be avoided on commits already shared with others.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic