Blog

A Developer’s Gitignore for AI: What You Should and Shouldn’t Commit

Learn what AI-related files and credentials to keep out of your version control and what is safe to commit.

Posted on: 2026-03-16 by AI Assistant


A Developer’s Gitignore for AI: What You Should and Shouldn’t Commit

As developers increasingly integrate AI models and APIs into their applications, project structures are changing. Alongside traditional source code, we now handle massive model weights, API keys for various providers, context cache files, and more.

In this tutorial, you will learn how to properly configure your .gitignore to keep sensitive credentials and bloated files out of your repositories, ensuring a secure and efficient development process.

Prerequisites

The Core .gitignore for AI Projects

When working with AI, it is crucial to ignore specific types of files that can pose security risks, violate licensing terms, or simply bloat your repository size.

Here is a recommended baseline .gitignore for AI development:

# AI API Keys and Credentials
.env
*.pem
*.key

# Local Model Weights (often large and binary)
*.safetensors
*.gguf
*.bin
*.pt
*.pth
*.ckpt
models/
weights/

# Hugging Face Cache
.cache/huggingface/
~/.cache/huggingface/

# Data and Context Caches
*.csv
*.jsonl
*.parquet
datasets/
data/raw/
data/processed/

# Notebook checkpoints
.ipynb_checkpoints/

Why Ignore These?

  1. Credentials (.env): Hardcoding or committing API keys (e.g., OpenAI, Anthropic, Gemini) is a major security risk. Always use environment variables and keep .env out of version control.
  2. Model Weights (*.gguf, *.safetensors): These files can be several gigabytes in size. Git is not designed to handle large binary blobs efficiently. Use Git LFS if you must version them, but it’s often better to download them programmatically.
  3. Datasets (*.parquet, *.csv): Similar to weights, large datasets can slow down repository cloning and operations.

What Should You Commit?

While much is ignored, certain AI-related artifacts should be versioned:

Next Steps

Now that your repository is secure and lean, you can confidently share your AI projects. For your next step, explore using Git LFS (Large File Storage) for managing datasets or model weights if you absolutely must track them alongside your code.