apply_changes
Stage specific lines or ranges from Git changes for partial commits, enabling multiple logical commits from a single file with intermixed changes, including untracked files.
Instructions
Stage selected lines to git index for partial commits (alternative to git add -p).
After using list_changes to view numbered changes, use this tool to selectively stage specific lines or ranges to the git index. This enables creating multiple logical commits from a single file with intermixed changes.
Unlike git add, this tool can stage parts of untracked files (newly created files).
You can commit only the first 10 lines of a new file while keeping the rest unstaged.
Number format examples:
Single lines: "0001,0002,0005"
Ranges: "0001-0010"
Combined: "0001-0005,0020-0025"
The tool updates the git index directly and reports remaining unstaged changes, allowing iterative staging for multiple commits from the same file.
Args: path: File path to apply changes to numbers: Change numbers in format: NNNN,MMMM,PPPP-QQQQ
Returns: JSON string with format: {applied: [{file, applied_count, after_applying: {diff, unstaged_lines}}], skipped, stats}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| numbers | Yes |