Create .gitignores with templates from gitignore.io
- Simple:
git ignore nodeto print thenodetemplate. - Offline first: Automatically caches templates for offline support.
- Aliases: Create aliases for commonly combined 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.
Currently, the only way to install this is to download the latest release binary for your platform and operating system.
To use this as demonstrated in the rest of this file, you'll need to assign an alias in your global .gitconfig file (usually ~/.gitconfig).
[alias]
ignore = !"path-to-binary"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!To list all the available templates:
$ git ignore --list
1c
1c-bitrix
a-frame
actionscript
ada
[...]
zukencr8000The --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 zig visualstudio
openframeworks+visualstudio
visualstudio
visualstudiocode
zigOnce 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 zig visualstudiocode
# Created by https://gitignore.io/api/visualstudiocode,zig
# Edit at https://gitignore.io/?templates=visualstudiocode,zig
### VisualStudioCode ###
[...]
### Zig ###
[...]
# End of https://gitignore.io/api/visualstudiocode,zigAliases are a way to combine common combinations of templates.
If you find yourself always using node and svelte in your frontend projects, you can create an alias for it for ease of access.
Aliases have higher priority than templates from gitignore.io, so an alias named node will be used instead of the template.
$ git ignore alias -l
zig => [linux, macos, visualstudiocode, windows, zig]$ git ignore alias -a node node svelte visualstudiocode
info: Added alias 'node' of [node, svelte, visualstudiocode]$ git ignore alias -r node
info: Removed alias 'node'