Skip to content

Git Operations

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.

Read-only operations to understand repository state.

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"]
}

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"

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_content
ToolPurpose
git_get_file_shaGet SHA hash of a specific file
git_get_last_commitRetrieve last commit SHA and message
git_get_changed_filesList files modified since last commit
git_validate_repoCheck if directory is a valid Git repository
git_contextAuto-detect Git context (repo, branch, status)

Essential Git workflow commands.

Configure the working directory for Git operations.

Parameters:

  • directory (required): Absolute path to the Git repository

Example:

{
"directory": "/home/user/my-project"
}

Stage files for commit.

Parameters:

  • paths (required): Array of file paths or patterns
  • all (optional): Stage all changes (equivalent to git add -A)

Examples:

// Add specific files
{
"paths": ["README.md", "src/main.go"]
}
// Add all changes
{
"all": true
}
// Add by pattern
{
"paths": ["*.md", "src/**/*.go"]
}

Create a commit with staged changes.

Parameters:

  • message (required): Commit message
  • author_name (optional): Override commit author name
  • author_email (optional): Override commit author email

Example:

{
"message": "feat: Add user authentication\n\nImplements OAuth2 flow with GitHub provider"
}

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
}

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
}

Switch branches or create new branch.

Parameters:

  • branch (required): Branch name
  • create (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
}

Understand history, manage branches, and organize work.

Analyze commit history with statistics.

Parameters:

  • limit (optional): Number of commits (default: 10)
  • author (optional): Filter by author
  • since (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": [...]
}

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"

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"
}
]
}
ToolPurpose
git_stashSave/apply/list temporary changes
git_remoteManage remote repositories
git_tagCreate/list/delete tags
git_cleanRemove untracked files

Sophisticated Git workflows for experienced users.

Merge branches with conflict detection.

Parameters:

  • branch (required): Branch to merge into current
  • strategy (optional): Merge strategy (recursive, ours, theirs)
  • no_ff (optional): Force merge commit (no fast-forward)

Example:

{
"branch": "feature-api",
"no_ff": true
}

Rebase current branch onto another.

Parameters:

  • branch (required): Target branch to rebase onto
  • interactive (optional): Enable interactive rebase

Example:

{
"branch": "main"
}

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 --force can overwrite other people’s work

Complete sync: fetch, merge/rebase, push.

Parameters:

  • remote (optional): Remote name (default: origin)
  • branch (optional): Branch name (default: current)
  • strategy (optional): merge or rebase (default: merge)

Example:

{
"strategy": "rebase"
}

Equivalent to:

Terminal window
git fetch origin
git rebase origin/main
git push origin main
ToolPurpose
git_checkout_remoteCheckout and track remote branch
git_pull_with_strategyPull with custom merge strategy
git_push_upstreamPush and set upstream tracking

Safe merge operations with backup and recovery.

Merge with automatic backup before operation.

Parameters:

  • branch (required): Branch to merge
  • backup_tag (optional): Custom backup tag name

Example:

{
"branch": "feature-risky",
"backup_tag": "before-risky-merge"
}

What it does:

  1. Creates backup tag
  2. Validates clean working directory
  3. Attempts merge
  4. Provides rollback command if conflicts occur

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_conflicts

Output:

{
"has_conflicts": true,
"conflicting_files": [
"src/components/Header.tsx",
"src/styles/main.css"
],
"can_auto_merge": false
}

Automatic conflict resolution strategies.

Parameters:

  • strategy (required): ours, theirs, or manual
  • files (optional): Specific files to resolve

Example:

{
"strategy": "theirs",
"files": ["package.json"]
}
ToolPurpose
git_conflict_statusList files with active conflicts
git_validate_clean_stateCheck if working directory is clean
git_create_backupManual backup creation
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_push
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)
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_status
  • 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

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.