Git Commit Editing

VerifiedSafe

This skill outlines how agents can edit previous commits using helper scripts instead of interactive rebase which requires a TTY.

Sby Skills Guide Bot
DevelopmentIntermediate
7/22/2026
Claude CodeCursorWindsurfCodex
#git#rebase#commit-history#version-control#automation

Recommended for

Automated summary

Lets an agent rewrite Git history (fixup, squash, drop, reword, reorder, edit) through non-interactive helper scripts, since `git rebase -i` requires a TTY.

Strengths

  • Provides a rebase script driven by a plan fed on stdin, enabling what `git rebase -i` forbids in a non-interactive environment.
  • Requires commits to be referenced by SHA rather than `HEAD~N`, avoiding fragile anchoring mistakes.
  • Covers common operations with dedicated shortcuts: `git commit --fixup/--squash` with `--autosquash`, a reword script, and the `edit` + `--amend` + `--rebase --continue` flow.
  • Ships a rationalizations table that corrects the workarounds agents tend to reach for (adding a new commit, undoing and redoing commits).

Limitations

  • Assumes the `non-interactive-git-rebase.sh` and `reword-commit.sh` scripts exist in the skills repo and are reachable by relative path.
  • Does not address conflict resolution beyond the `git rebase --continue` step mentioned for edit mode.
  • History rewriting stays risky on shared branches: the skill does not discuss force-push or collaboration safeguards.
When to use it

Use it when existing commits on a branch must be cleaned up or corrected and interactive rebase is unavailable.

When not to use it

Avoid it for undoing work already pushed to a shared branch, or when the helper scripts are not present in the environment.

Security analysis

Safe
Quality score85/100

The skill uses standard git commands (add, commit, amend, rebase) for legitimate version-control history editing. It does not contain destructive system operations, network calls, data exfiltration, or obfuscated payloads. The referenced helper scripts are not shown, but the instructions themselves pose no meaningful security risk.

No concerns found

How this analysis is made

Examples

Fold a fix into an earlier commit
My last two commits are just fixes for the config loader change three commits back. Use the git edit commit skill to fold them into that commit and drop their separate messages.
Drop and reorder commits
We have five commits on this branch and commit 3 adds a debug log I don't want, and commit 5 should come before commit 4. Rewrite the history with the non-interactive rebase script to drop the debug commit and reorder the rest.
Reword an old commit
The commit with SHA 4f2a9c1 has a vague message and no scope prefix. Use the reword script to change it to "fix(auth): handle expired refresh tokens".

description: Use when needing to fixup, squash, drop, reword, reorder, or edit commits in a branch's history. Handles the non-interactive approach agents need since git rebase -i requires a TTY.

Git Edit Commit

This skill outlines how agents can edit previous commits. Agents can't use git rebase -i directly, which requires a TTY. This skill provides helper scripts instead.

REQUIRED: Always reference commits by SHA, not by HEAD-relative notation like HEAD~3.

Inspect Commits First

Run git log --oneline to get SHAs. Output is newest-first; the rebase plan is oldest-first.

Amending the Latest Commit

To fold staged changes into the most recent commit without changing its message:

git add <files>
git commit --amend --no-edit

Fixup and Squash (Recommended Shortcut)

git commit --fixup=<target-sha>   # merge into target, discard message
git commit --squash=<target-sha>  # merge into target, combine messages

# <oldest-sha-in-scope>^ is the parent of the oldest commit in scope; use --root if it's the first commit
scripts/non-interactive-git-rebase.sh --autosquash <oldest-sha-in-scope>^

Drop, Reorder, Edit

Use scripts/non-interactive-git-rebase.sh. Supply the plan via stdin. Use --root when the oldest commit in scope is the repository's first commit.

scripts/non-interactive-git-rebase.sh <oldest-sha-in-scope>^ <<'PLAN'
pick abc1234 Keep this commit
squash def5678 Merge this into the previous
drop ghi9012 Remove this commit entirely
PLAN

Edit

Mark the commit edit in the plan. Git pauses there. Then:

git add <files>
git commit --amend --no-edit
git rebase --continue

Reword

scripts/reword-commit.sh --sha <sha> --message "New commit message"

Rationalizations

| Thought | Reality | | ------------------------------------------------- | ---------------------------------------------------------------- | | "I can't do interactive rebase without a TTY" | Use scripts/non-interactive-git-rebase.sh instead | | "I'll use HEAD~N as the upstream" | Use a SHA — HEAD~N is fragile and ambiguous | | "I'll just --amend instead" (for an older commit) | --amend only works on the latest commit; use rebase for others | | "I'll undo the commits and redo them one by one" | Rebase rewrites history in one step — no need to redo commits | | "I'll create a new commit to fix it" | That pollutes history; rebase is the right tool |

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/git-commit-editing-mrwakg8i/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/git-commit-editing-mrwakg8i' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/git-commit-editing-mrwakg8i/download' --output '.skill-downloads/git-commit-editing-mrwakg8i/SKILL.md.part' && mv '.skill-downloads/git-commit-editing-mrwakg8i/SKILL.md.part' '.skill-downloads/git-commit-editing-mrwakg8i/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

This file does not provide a usable name/description header for this native procedure. It remains available to download and inspect; use the manual method below.

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/git-commit-editing-mrwakg8i/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills