Git Operations
Overview
Section titled “Overview”34 Git tools for working against your local repository using native Git commands. No GitHub API quota is used. Set the workspace with git_set_workspace when you need to target a specific repository.
Information Tools (8)
Section titled “Information Tools (8)”Read-only operations to understand repository state.
git_status
Section titled “git_status”Get the current status of the Git repository.
Parameters: None (uses current working directory)
Example:
"What's the status of my repository?"Output:
{ "branch": "main", "tracking": "origin/main", "ahead": 2, "behind": 0, "staged": ["README.md"], "modified": ["src/main.go"], "untracked": ["test.txt"]}git_list_files
Section titled “git_list_files”List all tracked files in the repository.
Parameters:
pattern(optional): Glob pattern to filter files (e.g.,*.go,src/**/*.js)
Example:
"List all Go source files in my repository"→ Uses: git_list_files with pattern "*.go"git_get_file_content
Section titled “git_get_file_content”Retrieve contents of a specific file from Git.
Parameters:
path(required): Relative path to the file
Example:
"Show me the contents of src/main.go"→ Uses: git_get_file_contentOther Information Tools
Section titled “Other Information Tools”| Tool | Purpose |
|---|---|
git_get_file_sha | Get SHA hash of a specific file |
git_get_last_commit | Retrieve last commit SHA and message |
git_get_changed_files | List files modified since last commit |
git_validate_repo | Check if directory is a valid Git repository |
git_context | Auto-detect Git context (repo, branch, status) |
Basic Operations (6)
Section titled “Basic Operations (6)”Essential Git workflow commands.
git_set_workspace
Section titled “git_set_workspace”Configure the working directory for Git operations.
Parameters:
directory(required): Absolute path to the Git repository
Example:
{ "directory": "/home/user/my-project"}git_add
Section titled “git_add”Stage files for commit.
Parameters:
paths(required): Array of file paths or patternsall(optional): Stage all changes (equivalent togit add -A)
Examples:
// Add specific files{ "paths": ["README.md", "src/main.go"]}
// Add all changes{ "all": true}
// Add by pattern{ "paths": ["*.md", "src/**/*.go"]}git_commit
Section titled “git_commit”Create a commit with staged changes.
Parameters:
message(required): Commit messageauthor_name(optional): Override commit author nameauthor_email(optional): Override commit author email
Example:
{ "message": "feat: Add user authentication\n\nImplements OAuth2 flow with GitHub provider"}git_push
Section titled “git_push”Push commits to remote repository.
Parameters:
remote(optional): Remote name (default:origin)branch(optional): Branch name (default: current branch)force(optional): Use--force-with-lease(safer than--force)
Examples:
// Simple push{}
// Push to specific remote/branch{ "remote": "upstream", "branch": "feature-branch"}
// Force push (safe){ "force": true}git_pull
Section titled “git_pull”Fetch and merge changes from remote.
Parameters:
remote(optional): Remote name (default:origin)branch(optional): Branch name (default: current branch)rebase(optional): Use rebase instead of merge
Example:
{ "rebase": true}git_checkout
Section titled “git_checkout”Switch branches or create new branch.
Parameters:
branch(required): Branch namecreate(optional): Create new branch if it doesn’t exist
Examples:
// Switch to existing branch{ "branch": "develop"}
// Create and switch to new branch{ "branch": "feature-new-ui", "create": true}Analysis & Management (7)
Section titled “Analysis & Management (7)”Understand history, manage branches, and organize work.
git_log_analysis
Section titled “git_log_analysis”Analyze commit history with statistics.
Parameters:
limit(optional): Number of commits (default: 10)author(optional): Filter by authorsince(optional): Filter commits since date (e.g., “2 weeks ago”)
Example:
{ "limit": 20, "author": "john@example.com", "since": "1 month ago"}Output:
{ "commits": 20, "authors": ["john@example.com", "jane@example.com"], "files_changed": 45, "insertions": 892, "deletions": 234, "commits_list": [...]}git_diff_files
Section titled “git_diff_files”Show modified files with statistics.
Parameters:
target(optional): Compare against branch/commit (default: HEAD)
Example:
"Show me what changed compared to main branch"→ Uses: git_diff_files with target "main"git_branch_list
Section titled “git_branch_list”List all branches with metadata.
Parameters: None
Output:
{ "current": "feature-auth", "branches": [ { "name": "main", "remote": "origin/main", "last_commit": "Fix login bug", "last_author": "john@example.com", "last_date": "2 hours ago" }, { "name": "feature-auth", "current": true, "last_commit": "Add OAuth2 flow", "last_author": "You", "last_date": "10 minutes ago" } ]}Other Analysis Tools
Section titled “Other Analysis Tools”| Tool | Purpose |
|---|---|
git_stash | Save/apply/list temporary changes |
git_remote | Manage remote repositories |
git_tag | Create/list/delete tags |
git_clean | Remove untracked files |
Advanced Operations (7)
Section titled “Advanced Operations (7)”Sophisticated Git workflows for experienced users.
git_merge
Section titled “git_merge”Merge branches with conflict detection.
Parameters:
branch(required): Branch to merge into currentstrategy(optional): Merge strategy (recursive,ours,theirs)no_ff(optional): Force merge commit (no fast-forward)
Example:
{ "branch": "feature-api", "no_ff": true}git_rebase
Section titled “git_rebase”Rebase current branch onto another.
Parameters:
branch(required): Target branch to rebase ontointeractive(optional): Enable interactive rebase
Example:
{ "branch": "main"}git_force_push
Section titled “git_force_push”Force push with --force-with-lease (safer than --force).
Parameters:
remote(optional): Remote name (default:origin)branch(optional): Branch name (default: current)
Why --force-with-lease?
- ✅ Fails if remote has changes you don’t have locally
- ❌ Regular
--forcecan overwrite other people’s work
git_sync_with_remote
Section titled “git_sync_with_remote”Complete sync: fetch, merge/rebase, push.
Parameters:
remote(optional): Remote name (default:origin)branch(optional): Branch name (default: current)strategy(optional):mergeorrebase(default:merge)
Example:
{ "strategy": "rebase"}Equivalent to:
git fetch origingit rebase origin/maingit push origin mainOther Advanced Tools
Section titled “Other Advanced Tools”| Tool | Purpose |
|---|---|
git_checkout_remote | Checkout and track remote branch |
git_pull_with_strategy | Pull with custom merge strategy |
git_push_upstream | Push and set upstream tracking |
Conflict Management (6)
Section titled “Conflict Management (6)”Safe merge operations with backup and recovery.
git_safe_merge
Section titled “git_safe_merge”Merge with automatic backup before operation.
Parameters:
branch(required): Branch to mergebackup_tag(optional): Custom backup tag name
Example:
{ "branch": "feature-risky", "backup_tag": "before-risky-merge"}What it does:
- Creates backup tag
- Validates clean working directory
- Attempts merge
- Provides rollback command if conflicts occur
git_detect_conflicts
Section titled “git_detect_conflicts”Preview potential merge conflicts without merging.
Parameters:
branch(required): Branch to check against
Example:
"Would merging feature-ui into main cause conflicts?"→ Uses: git_detect_conflictsOutput:
{ "has_conflicts": true, "conflicting_files": [ "src/components/Header.tsx", "src/styles/main.css" ], "can_auto_merge": false}git_resolve_conflicts
Section titled “git_resolve_conflicts”Automatic conflict resolution strategies.
Parameters:
strategy(required):ours,theirs, ormanualfiles(optional): Specific files to resolve
Example:
{ "strategy": "theirs", "files": ["package.json"]}Other Conflict Tools
Section titled “Other Conflict Tools”| Tool | Purpose |
|---|---|
git_conflict_status | List files with active conflicts |
git_validate_clean_state | Check if working directory is clean |
git_create_backup | Manual backup creation |
Common Workflows
Section titled “Common Workflows”Starting New Feature
Section titled “Starting New Feature”1. "Switch to main and pull latest changes" → git_checkout + git_pull
2. "Create a new branch called feature-login" → git_checkout with create: true
3. [Make your changes in editor]
4. "Stage all changes and commit with message 'Add login form'" → git_add + git_commit
5. "Push to remote" → git_pushSyncing with Team
Section titled “Syncing with Team”1. "What's my current Git status?" → git_status
2. "Fetch and rebase with main" → git_sync_with_remote with strategy: rebase
3. "Force push safely" → git_force_push (uses --force-with-lease)Safe Merge
Section titled “Safe Merge”1. "Check if merging feature-api would cause conflicts" → git_detect_conflicts
2. "Safely merge feature-api with backup" → git_safe_merge
3. [If conflicts] "Show me the conflict status" → git_conflict_statusLimitations
Section titled “Limitations”- Requires Git installed: These tools need Git CLI available on the system
- Local operations only: Cannot create remote repositories (use GitHub API tools instead)
- No GUI operations: All operations are CLI-based
Responsible use
Section titled “Responsible use”All commands run against the workspace you specify. Verify paths, branches, and changes before committing or pushing. We are not responsible for misuse or resulting damage.