.gitignore

A .gitignore file tells version control which files and directories to exclude from tracking. For vibe coders, a proper .gitignore is critical — AI-generated projects often create node_modules, environment files with API keys, build artifacts, and other files that should never be committed to a repository.

Example

Your AI assistant generates a complete project with a .env file containing your OpenAI API key. Without a .gitignore, that key gets pushed to GitHub and exposed publicly. A proper .gitignore excludes .env, node_modules, and build output automatically.

A .gitignore file is a small file with an outsized impact on security. It's one of the first things to set up in any vibe-coded project.

What to Ignore

Always Ignore

  • Environment files.env, .env.local, .env.production
  • Dependenciesnode_modules/, vendor/, venv/
  • Build outputdist/, build/, .next/
  • IDE files.vscode/settings.json, .idea/
  • OS files.DS_Store, Thumbs.db

Never Ignore

  • Source code — Your actual application files
  • Configurationpackage.json, tsconfig.json
  • Lock filespackage-lock.json, bun.lockb
  • Documentation — README, license files

The Security Risk

Exposing secrets in version control is one of the most common security mistakes:

  1. API keys get committed accidentally
  2. Keys end up on public GitHub repositories
  3. Bots scan GitHub for exposed keys within minutes
  4. Your accounts get compromised

A .gitignore prevents this entirely.

Setting Up .gitignore

Most AI tools generate a .gitignore when scaffolding a project. Always verify it includes:

  1. Environment and secret files
  2. Dependency directories
  3. Build artifacts
  4. System-specific files

If AI doesn't generate one, ask: "Create a .gitignore for this project that excludes secrets, dependencies, and build output."