- Generate .gitignore based on the contents of the local directory. (by default, the contents of github/gitignore are used)
- Completion in Fish, Bash, Zsh
- Works on Linux, Windows, MacOS
Install git-ignore
with cargo:
cargo install git-ignore --git https://github.com/r4ai/git-ignore
And then, register it as a subcommand of git:
sudo git-ignore --register
Generate a .gitignore file for Rust:
git ignore rust > .gitignore
Generate a .gitignore file for Rust, Python, and C++:
git ignore rust python c++ > .gitignore
Add the following line to your ~/.config/fish/config.fish
:
test -e (git --exec-path)/git-ignore; and source (git ignore --completion fish | psub)
This will enable completion for git ignore
subcommand.
Add the following line to your ~/.bashrc
:
if [ -f "$(git --exec-path)/git-ignore" ]; then
source <(git ignore --completion bash)
fi
This will enable completion for git ignore
subcommand.
Run the following command:
git ignore --completion zsh > ~/.zsh/completions/_git-ignore
This will enable completion for git ignore
subcommand.
Warning
~/.zsh/completions
have to be in your $fpath
. Change this path if necessary.
To check if it is in your $fpath
, run echo $fpath
.
If you don't have ~/.zsh/completions
, create it and add the following line to your ~/.zshrc
:
fpath=(~/.zsh/completions $fpath)
This command generates .gitignore
based on the local directory.
By default, this directory is /home/alice/.local/share/gitignore
, where the repository at github/gitignore is cloned. You can also check the path of this directory with git ignore --repo
.
To change the path of this directory, you need to change ignore.path
in git config.
git config --global ignore.path /path/to/your/gitignore
For example, if you want to use toptal/gitignore instead of github/gitignore, simply clone toptal/gitignore to /home/alice/.local/share/gitignore
:
$ git ignore --repo
/home/alice/.local/share/gitignore
$ cd /home/alice/.local/share
$ rm -rf ./gitignore
$ gh repo clone toptal/gitignore
Clone repository:
gh repo clone r4ai/git-ignore
Build and install git-ignore
from local repositories.
cargo install --path .
Register it as a subcommand of git:
git-ignore --register
MIT License