Ignore files locally in Git when you can’t use .gitignore
.
git-ignore-local
is a lightweight command-line tool that integrates with Git to help you ignore files using .git/info/exclude
. This is useful when you want to ignore files locally but don’t want to (or can't) commit changes to .gitignore
, such as machine-specific configs, debug logs, or IDE files.
-
Download the prebuilt binary for your OS and architecture from the Releases page,
or build it yourself by running:./build.sh
-
Install it as a Git subcommand:
sudo cp build/git-ignore-local-<your-platform> /usr/local/bin/git-ignore-local chmod +x /usr/local/bin/git-ignore-local
You can now use it via:
git ignore-local
git ignore-local <pattern1> <pattern2> ...
Example:
git ignore-local .env logs/debug.log config/dev.yaml
This appends the given patterns to .git/info/exclude
.
git ignore-local --restore <pattern1> <pattern2> ...
Example:
git ignore-local --restore logs/debug.log
This removes matching lines from .git/info/exclude
.
-
All paths or patterns must be specified relative to the root of the Git repository.
For example, if your Git project is located at:
/home/user/my-project/
And you want to ignore this file:
/home/user/my-project/logs/debug.log
You should run:
git ignore-local logs/debug.log
Do not use absolute paths or paths relative to your shell location. Always start from the Git root.
If you find a bug or unexpected behavior, please open an issue in the repository. Contributions and feedback are welcome.