amend

Amend the most recent unpublished Git commit with force-with-lease safety.

Updated Dec 21, 2018
One-click install
npx skills add https://github.com/dhnt/dhnt --skill amend-dhnt
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: amend
Source: https://github.com/dhnt/dhnt/tree/main/catalog/md/commit/amend
Command: npx skills add https://github.com/dhnt/dhnt --skill amend-dhnt

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you correct mistakes in your most recent Git commit without creating an unnecessary new commit, while avoiding the history-rewrite risks of amending commits that are already shared.

Core Features & Use Cases

  • Message-only fixes: Update the commit message when only the wording is wrong.
  • Add missing content: Include staged file changes by amending the latest commit without changing its existing message (unless you choose to).
  • Small, private corrections: Use when the commit is not published (not yet pushed/shared) and the fix is trivial and chronological clean-up is acceptable.
  • Safety guidance: Clear rules for when NOT to amend (e.g., already pushed, failed pre-commit hook, non-trivial changes, or other authors’ commits).

Quick Start

Tell the AI to amend your most recent commit only if it has not been published yet, and to guide you through whether you should use a message-only amendment or include staged file changes.

Frequently Asked Questions about amend

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix a typo in my last Git commit message without creating a new commit?

To fix a typo in your last commit message without a new commit, use git commit --amend. This updates the most recent commit object directly, allowing you to rewrite the message while keeping your history clean before publishing.

How can I add a forgotten staged file to my most recent git commit?

To add a forgotten staged file to your most recent git commit, stage the missing file and run git commit --amend. This applies your staged changes to the previous commit without altering its original message unless you explicitly choose to update it.

When is it safe to amend a git commit?

It is safe to amend a git commit only when the commit is private and has not been published to a shared remote yet. You should avoid amending commits that are already pushed, have failed pre-commit hooks, or contain non-trivial changes from other authors.

Why should I use force-with-lease when pushing an amended commit?

You should use force-with-lease when pushing an amended commit to enforce safety during history rewrites. It prevents overwriting changes made by collaborators on the remote branch, ensuring you only force push if no one else has uploaded new commits.

What is the best way to apply a trivial correction to a private commit before pushing?

The best way to apply a trivial correction to a private commit before pushing is git commit --amend. It folds your staged changes or updated message into the previous commit, maintaining chronological clean-up for small, unpublished developer workflow corrections.