Diff one file between two refs
diff_fileShow the unified diff of one file between two Git refs, scoped by path, without a working tree. Use it to review changes for a specific file across branches or commits.
Instructions
The unified diff of one file between two refs — git diff -M <from> <to> -- <path> — without a working tree. The caller names the file and the diff is scoped before git runs, so nothing is found by parsing a patch header. context sets the lines shown around each hunk (default 3, 0-10) and max_bytes caps the diff. Scoping by path narrows rename detection, so a renamed file is read as an added (or deleted) file. The two refs are a raw two-dot diff: pass a merge_base printed by compare as from for the branch view of one file. A file that is unchanged between the refs yields no diff, and one absent from both is reported as not found. A binary file is refused: git has only a "Binary files … differ" line for it, which is not a patch.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | The ref to diff to, e.g. 'fix/PROJ-7608'. | |
| from | Yes | The ref to diff from, e.g. 'develop' or a commit sha. | |
| path | Yes | File path from the repository root, e.g. 'src/index.tsx'. | |
| context | No | Lines of context on each side of a hunk (default 3, at most 10). Use 0 for the fewest lines. | |
| project | No | GitLab project path, e.g. 'group/subgroup/repo'. Defaults to GITLAB_DEFAULT_PROJECT. | |
| max_bytes | No | Byte cap for the patch (default 200000). A cut patch is marked in the result. |