.gitignore for Hardhat
9 ignore rules for Hardhat, ready to copy into your repository.
Ethereum development environment for smart contracts
The complete .gitignore for Hardhat
# Generated by LFGitignore - https://lfgitignore.com
# Created: 2026-09-17 17:00:55 UTC
# Technologies: Hardhat
### Hardhat ###
# Compiled contract artifacts
/artifacts
/cache
/types
# Environment variables
.env
.env.*
!.env.example
/coverage
# Gas snapshot file
/.gas-snapshot
/snapshots
What these Hardhat rules actually ignore
Every pattern below, and why it belongs in your .gitignore.
Hardhat Build Artifacts
| Pattern | What it ignores |
|---|---|
/artifacts |
Compiled contract artifacts |
Hardhat compilation (v2) support directory
| Pattern | What it ignores |
|---|---|
/cache |
Hardhat compilation (v2) support directory |
Typechain output
| Pattern | What it ignores |
|---|---|
/types |
Typechain output |
Environment files
| Pattern | What it ignores |
|---|---|
.env |
Environment variables |
.env.* |
Environment files |
!.env.example |
Environment files |
Hardhat coverage reports
| Pattern | What it ignores |
|---|---|
/coverage |
Hardhat coverage reports |
Gas snapshot files
| Pattern | What it ignores |
|---|---|
/.gas-snapshot |
Gas snapshot file |
Snapshot cheatcodes output
| Pattern | What it ignores |
|---|---|
/snapshots |
Snapshot cheatcodes output |
How to use this .gitignore for Hardhat
- Copy the Hardhat rules above, or download the file directly.
- Create a file named .gitignore at the root of your Git repository and paste the rules into it.
- If some of those files are already tracked, run git rm -r --cached . then commit again — Git only applies ignore rules to untracked files.
- Commit the .gitignore so everyone on the team shares the same rules.