🔧 Error Fixes
· 2 min read

Aider Git Error Fix: Common Aider Issues and Solutions (2026)


Aider is a powerful AI pair programmer but it has specific requirements around git, model connections, and file handling. Here are the most common errors and fixes.

”Not a git repository”

Git repo not found. Aider needs to run inside a git repository.

Aider requires git for tracking changes:

git init
git add -A
git commit -m "Initial commit"
aider

“Model not found” or connection errors

Error: Could not connect to model
# For OpenAI models
export OPENAI_API_KEY=sk-...
aider --model gpt-5.4

# For Anthropic/Claude
export ANTHROPIC_API_KEY=sk-ant-...
aider --model claude-sonnet-4

# For Ollama (local)
aider --model ollama/qwen3:8b

# For OpenRouter
export OPENROUTER_API_KEY=sk-or-...
aider --model openrouter/anthropic/claude-sonnet-4

# For DeepSeek
export DEEPSEEK_API_KEY=sk-...
aider --model deepseek/deepseek-chat

See our guides for specific setups: Aider with Ollama, Aider with DeepSeek, MiMo V2 Pro with Aider.

”File not in git”

Warning: file.txt is not in the git repo

Aider only edits files tracked by git:

git add src/new-file.ts
aider src/new-file.ts

Context overflow / token limit

Warning: messages exceed model context window

The conversation got too long for the model’s context:

# Clear context and start fresh
/clear

# Or drop files from context
/drop src/large-file.ts

# Use a model with larger context
aider --model claude-sonnet-4  # 200K context
aider --model gpt-5.4          # 1M context

Aider makes wrong edits

If Aider edits the wrong files or makes incorrect changes:

# Undo the last change (Aider auto-commits)
/undo

# Or use git
git diff HEAD~1  # See what changed
git reset --hard HEAD~1  # Revert

Always run Aider on a branch so you can easily discard changes:

git checkout -b ai-refactor
aider "Refactor the auth module"
# If happy: git checkout main && git merge ai-refactor
# If not: git checkout main && git branch -D ai-refactor

Slow responses with Ollama

If Aider + Ollama is slow:

# Use a smaller model
aider --model ollama/qwen3:8b  # Instead of 27b

# Reduce context
aider --model ollama/qwen3:8b --map-tokens 1024

# Check Ollama is using GPU
ollama ps  # Should show GPU

See our Ollama slow inference fix for more optimization tips.

”Encoding error” or Unicode issues

UnicodeDecodeError: 'utf-8' codec can't decode byte

Aider can’t read binary files or files with non-UTF-8 encoding:

# Exclude binary files
aider --exclude "*.png" --exclude "*.jpg" --exclude "*.woff2"

# Or specify only the files you want
aider src/app.ts src/auth.ts

Best practices to avoid errors

  1. Always work in a git repo with a clean working tree
  2. Use branches for AI-assisted changes
  3. Start with small, specific requests before complex refactors
  4. Check /tokens regularly to monitor context usage
  5. Use /undo immediately if something goes wrong

Related: Aider Complete Guide · Aider with Ollama Setup · Aider with DeepSeek · Ollama Out of Memory Fix · Best AI Coding Tools