git-surgical-staging

Stage precise lines from files using git diff and git apply --cached.

21|Updated Jan 11, 2022
One-click install
npx skills add https://github.com/collinarnett/brew --skill git-surgical-staging
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-surgical-staging
Source: https://github.com/collinarnett/brew/tree/main/configurations/claude-code/skills/git-surgical-staging
Command: npx skills add https://github.com/collinarnett/brew --skill git-surgical-staging

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Stage precise lines from a file to create atomic, meaningful commits that reflect distinct changes rather than bundling all edits together.

Core Features & Use Cases

  • Line-level staging by constructing a filtered patch and applying it to the index via git apply --cached.
  • Supports planning and grouping changes to ensure commits are logical and independent.
  • Works within standard Git workflows without external tools, suitable for refactors, bugfixes, and feature work.

Quick Start

Stage a selected region from a modified file to craft a focused commit.

Frequently Asked Questions about git-surgical-staging

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

FAQPage Schema
How do I stage specific lines in git for atomic commits?

To stage specific lines in git for atomic commits, you construct a filtered patch from the git diff and apply it to the index using git apply --cached. This enables granular, non-interactive line-level staging across multiple files.

What is the best way to separate intermixed changes in a git file into logical commits?

Separating intermixed changes in a git file into logical commits requires line-level staging to group distinct edits. By constructing a filtered patch and applying it to the index, you ensure commits are atomic, meaningful, and independent.

Can I stage individual lines across multiple files without interactive tools?

Yes, you can stage individual lines across multiple files without interactive tools by generating a filtered patch from git diff. Applying this patch to the index with git apply --cached satisfies non-interactive line-level staging requirements in standard workflows.

Does line-level staging with git apply work for refactoring and bugfix workflows?

Line-level staging with git apply works effectively for refactoring and bugfix workflows within standard Git environments. It supports planning and grouping changes to ensure commits reflect distinct logical modifications without requiring external tools.

Why should I use git apply --cached instead of git add for staging partial file changes?

Using git apply --cached instead of git add for staging partial file changes allows precise, line-level control by applying a filtered patch directly to the index. This ensures atomic commits by staging exact lines rather than entire file modifications.

When do I need line-level staging in version control?

You need line-level staging in version control when changes are intermixed within files and you must create clean, atomic commits. It allows you to construct a filtered patch from git diff to stage exact lines reflecting distinct changes.