Git Diff
git_diffCompare Git commits, branches, or working tree states to view code differences in unified diff format. Review staged or unstaged changes, analyze file statistics, and filter by specific paths to track modifications.
Instructions
View differences between commits, branches, or working tree. Shows changes in unified diff format.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Path to the Git repository. Defaults to session working directory set via git_set_working_dir. | . |
| target | No | Target commit/branch to compare against. If not specified, shows unstaged changes in working tree. | |
| source | No | Source commit/branch to compare from. If target is specified but not source, compares target against working tree. | |
| paths | No | Limit diff to specific file paths (relative to repository root). | |
| staged | No | Show diff of staged changes instead of unstaged. | |
| includeUntracked | No | Include untracked files in the diff. Useful for reviewing all upcoming changes. | |
| nameOnly | No | Show only names of changed files, not the diff content. | |
| stat | No | Show diffstat (summary of changes) instead of full diff content. | |
| contextLines | No | Number of context lines to show around changes. | |
| autoExclude | No | Automatically exclude lock files and other generated files (e.g., package-lock.json, yarn.lock, bun.lock, poetry.lock, go.sum) from diff output to reduce context bloat. Set to false if you need to inspect these files. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| success | Yes | Indicates if the operation was successful. | |
| diff | Yes | The diff output in unified diff format. | |
| filesChanged | Yes | Number of files with differences. | |
| insertions | No | Total number of line insertions. | |
| deletions | No | Total number of line deletions. | |
| excludedFiles | No | Files that were automatically excluded from the diff (e.g., lock files). Call again with autoExclude=false to include them. |