QuestenaPractice that shows what to review next
Question 3

What does `git commit --amend` actually do to the commit at the tip of the current branch?

  1. Edits the existing commit object in place, keeping its original hash
  2. Adds a fixup commit on top that Git later squashes automatically
  3. Changes only the commit message; all the staged content is left for a separate follow-up commit
  4. Creates a new commit object that replaces the tip commit, so the tip normally gets a new hashCorrect answer

Explanation

Commit objects are immutable, so 'amending' actually builds a new commit (from the current index and the edited message) and makes the branch point at it; the old commit is no longer on the branch. This is why amending an already-pushed commit makes your branch diverge from the remote. The 'in place, same hash' option is the common misconception; and --amend can change content, not just the message.

Continue with this test

Start practice
Question 3: What does `git commit --amend` actually do to the commit at… · Git Fundamentals · Questena