Crates.io | git-ignore-generator |
lib.rs | git-ignore-generator |
version | 1.4.0 |
source | src |
created_at | 2018-11-05 22:00:04.059744 |
updated_at | 2024-07-23 12:16:44.216326 |
description | Quickly and easily fetch .gitignore templates from www.gitignore.io |
homepage | https://github.com/sondr3/git-ignore |
repository | https://github.com/sondr3/git-ignore |
max_upload_size | |
id | 94903 |
size | 289,468 |
Create .gitignores with templates from www.gitignore.io, your own aliases and templates
git ignore node
to print the node
template..gitignore
by matching common files against templates.Tired of visiting gitignore.io to get templates for your
.gitignore
all the time? I was. So I automated it.
git ignore
allows you to easily and quickly get all the available templates from
gitignore.io, even while offline. You can also define
your own aliases for common combinations of templates, or create your own completely
custom ones for even more power.
NOTE: Similar to the nix-search
command, this program prints a message
to stderr
about using cached results. This does not interfere with piping
and is purely informational. You can also optionally use --write
to automatically
write the resulting ignores to $CWD/.gitignore
instead of piping.
To download and cache all available templates, use --update
. This can also be
used in combination with any of the other flags/arguments, or be run as a
standalone flag.
$ git ignore -u
Info: Update successful
By matching against project or language specific files and extensions you can have
your .gitignore
automatically generated for you. Do you have a package.json
and
Cargo.toml
in the current directory? --auto
will automatically add node
and rust
to the template output.
$ git ignore -a
### Created by https://www.gitignore.io
### Rust ###
[...]
# These are backup files generated by rustfmt
**/*.rs.bk
To list all the available templates:
$ git ignore --list
1c
1c-bitrix
a-frame
actionscript
ada
[...]
zukencr8000
The --list
option is also used to search for templates matching your input. The
matching is done by doing template.contains(phrase)
, so searching for intellij
will list all templates containing that phrase. You can also search for multiple
templates at once:
$ git ignore -l rust intellij
intellij
intellij+all
intellij+iml
rust
Once you've found your templates, you can print them by omitting -l|--list
. Note:
listing and searching for templates is inexact, but printing them requires exact matches.
$ git ignore rust intellij+all
### Created by https://www.gitignore.io
### Rust ###
[...]
# These are backup files generated by rustfmt
**/*.rs.bk
Aliases are a way to combine common combinations of templates, if you find
yourself always using node
and visualstudiocode
in your frontend projects
you can create an alias for it for ease of access. Aliases have higher priority
than templates from www.gitignore.io, so an alias named node
will be used
instead of the template. When listing all available templates, aliases are colored
yellow to allow you to distinguish them from regular templates.
$ git ignore alias list
Available aliases:
node => ["node", "nextjs", "visualstudiocode"]
rust => ["rust", "intellij+all"]
$ git ignore alias add node node nextjs visualstudiocode
Created alias node for ["node", "nextjs", "visualstudiocode"]
$ git ignore alias remove node
Removed alias node
Templates are custom templates created by you for things that do not have an
existing template defined. When listing and searching templates has the highest
priority (templates > alias > normal
). Templates are listed with a blue color
to distinguish them from aliases and normal templates.
The file name is the name of the file in $HOME/.config/git-ignore/templates
.
$ git ignore template list
Available templates:
docs => "docs.txt"
All templates are created in $HOME/.config/git-ignore/templates
. So the name
you give for the file is the filename that is used in this directory.
$ git ignore template add docs docs.txt
Created template docs at ~/.config/git-config/templates/docs.txt
$ git ignore template remove node
Removed template node
You can create the configuration file and directories by running git ignore init
. This
will create $HOME/.config/git-ignore/config.toml
and $HOME/.config/git-ignore/templates/
.
The config file is a simple TOML file:
[aliases]
node = [
'node',
'nextjs',
'visualstudiocode',
]
[templates]
docs = 'docs.txt'
If your method of installation didn't include shell completion, you can manually
source or save them with the git ignore completion <shell>
command.
Finally, help is always available with git ignore help
/git ignore -h
(or --help
if your installation
included man pages).
Currently, the package is available a couple of places, including Homebrew, AUR and Nix.
cargo install git-ignore-generator
nix-env -iA nixpkgs.gitAndTools.git-ignore
brew tap sondr3/homebrew-taps
brew install git-ignore
paru
with you favorite AUR tool)paru git-ignore-bin
paru git-ignore
You can also download the matching release from the release
tab, extracting the archive and
placing the binary in your $PATH
. Note that for Linux the
unknown-linux-musl.tar.gz
is preferred as it is statically linked and thus
should run on any Linux distribution.
GPLv3+.