A CLI tool to manage .gitignore files. Quickly add patterns or generate complete templates from gitignore.io.
cargo install --path .Or build from source:
cargo build --releaseThe binary will be available at target/release/git-ignore.
git-ignore node_modules
git-ignore "*.log"
git-ignore .envPatterns are appended to the existing .gitignore file (or created if it doesn't exist). Duplicate patterns are detected and skipped.
A preset is a language or tool name, such as go, rust or java:
git-ignore new rustCombine as many as you like, space- or comma-separated:
git-ignore new go rust java
git-ignore new rust,visualstudiocode,macosIf there is no .gitignore yet, the preset is written as-is. If one already
exists, the presets are merged into it: your file is kept, and only patterns
it doesn't already have are appended under a # Added by git-ignore heading.
Template sections left with nothing new to add are skipped entirely, so a second
run of the same preset changes nothing.
To replace an existing .gitignore instead of merging, pass -f:
git-ignore new rust -f
-n/--newis a deprecated alias fornewand behaves identically, including the merge default:git-ignore -n rustmerges,git-ignore -n rust -foverwrites.
git-ignore -lgit-ignore verifyChecks the .gitignore in the current directory and reports:
- Duplicate patterns – a line that repeats an earlier one and has no effect. Repeats that follow an opposite (negated) pattern are not reported, since they still change the result.
- Patterns that match nothing – no file or directory under the current directory (excluding
.git) matches the pattern.
Exits with status 1 if any problems are found, so it can be used in CI.
Generate completions for your shell:
# Bash
git-ignore completions bash >> ~/.bashrc
# Zsh
git-ignore completions zsh >> ~/.zshrc
# Fish
git-ignore completions fish > ~/.config/fish/completions/git-ignore.fishFor preset name completion after new (and the -n flag), first update the local cache:
git-ignore update-cacheThen regenerate your shell completions.
| Command | Description |
|---|---|
git-ignore <pattern> |
Add a pattern to .gitignore |
git-ignore new <preset>... |
Merge preset(s) into .gitignore |
git-ignore new <preset> -f |
Overwrite .gitignore with preset(s) |
git-ignore -l |
List available templates |
git-ignore completions <shell> |
Generate shell completions |
git-ignore update-cache |
Update local template cache |
git-ignore verify |
Check .gitignore for duplicate and unmatched patterns |
MIT