Skip to content

Git commit amend

Git commit amend is a command-line operation used to modify the most recent commit in a repository's history.^[600-developer-tools-git-git-command.md]

Functionality

The git commit --amend command allows developers to incorporate staged changes into the previous commit or alter the commit message without creating a new commit ID^[600-developer-tools-git-git-command.md].

This tool is useful for correcting mistakes immediately after a commit, such as adding a forgotten file or fixing a typo in the commit message^[600-developer-tools-git-git-command.md].

Common Use Cases

  1. Modifying the commit message: Running git commit --amend opens the editor to change the message of the last commit^[600-developer-tools-git-git-command.md].
  2. Adding files to the previous commit: Running git commit --amend <file1> <file2> adds the specified files to the last commit^[600-developer-tools-git-git-command.md].

Sources

^[600-developer-tools-git-git-command.md]