Amending the last commit
Amending a commit in Git allows you to modify the most recent commit. This can include changing the commit message, adding new changes, or removing changes from the commit.
When to use amending:
- Fixing typos or errors in commit messages: If you notice a mistake in the commit message right after committing, you can amend the commit to correct the message without creating a new commit.
- Adding forgotten changes: If you forgot to include some changes in the last commit, you can stage the new changes and amend the previous commit to include them.
- Removing unintended changes: If the last commit included unintended changes, you can amend to remove them.
Use git commit --amend to modify the most recent commit.