.gitignore for Foundry

11 ignore rules for Foundry, ready to copy into your repository.

Fast toolkit for Ethereum smart contract development

The complete .gitignore for Foundry

# Generated by LFGitignore - https://lfgitignore.com
# Created: 2026-09-17 17:00:55 UTC
# Technologies: Foundry

### Foundry ###
cache/
out/
.logs/
.ignore/
!/broadcast
# Forge script broadcasts on local Anvil chain
/broadcast/*/31337/
# Forge script dry-run broadcast logs
/broadcast/**/dry-run/
docs/
# Environment variables
.env
.env.*
!.env.example

What these Foundry rules actually ignore

Every pattern below, and why it belongs in your .gitignore.

Compiler files

Pattern What it ignores
cache/ Compiler files
out/ Compiler files

Commonly ignored directories

Pattern What it ignores
.logs/ Commonly ignored directories
.ignore/ Commonly ignored directories

Ignores development broadcast logs

Pattern What it ignores
!/broadcast Ignores development broadcast logs
/broadcast/*/31337/ Forge script broadcasts on local Anvil chain
/broadcast/**/dry-run/ Forge script dry-run broadcast logs

Docs

Pattern What it ignores
docs/ Docs

Dotenv file

Pattern What it ignores
.env Environment variables
.env.* Dotenv file
!.env.example Dotenv file

How to use this .gitignore for Foundry

  1. Copy the Foundry rules above, or download the file directly.
  2. Create a file named .gitignore at the root of your Git repository and paste the rules into it.
  3. If some of those files are already tracked, run git rm -r --cached . then commit again — Git only applies ignore rules to untracked files.
  4. Commit the .gitignore so everyone on the team shares the same rules.

Other Framework .gitignore templates

See every Framework template