iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
💮

Generating .gitignore with gibo

に公開

When creating a Git repository, deciding what to include in .gitignore can be a bit of a headache (usually, we end up copying it from somewhere else). However, using a tool called gibo allows you to generate .gitignore boilerplates quite nicely.

Installation and Preparation

The installation method is described in README.md, so you can refer to that. Since the minimum requirement is just the gibo or gibo.bat script, it should be easy to set up.

For now, drop the script into a directory included in your PATH and try running gibo help (the -h option also works).

$ gibo help
gibo 2.2.4 by Simon Whitaker <sw@netcetera.org>
https://github.com/simonwhitaker/gibo

Fetches gitignore boilerplates from https://github.com/github/gitignore

Usage:
    gibo [command]

Example:
    gibo dump Swift Xcode >> .gitignore

Commands:
    dump BOILERPLATE...   Write boilerplate(s) to STDOUT
    help                  Display this help text
    list                  List available boilerplates
    root                  Show the directory where gibo stores its boilerplates
    search STR            Search for boilerplates with STR in the name
    update                Update list of available boilerplates
    version               Display current script version

As preparation, start by updating the .gitignore information.

$ gibo update
Cloning https://github.com/github/gitignore.git to /home/username/.gitignore-boilerplates
Cloning into '/home/username/.gitignore-boilerplates'...
...

This sets up the information in the $HOME/.gitignore-boilerplates directory. By the way, on Windows, it is set in the %APPDATA%\.gitignore-boilerplates folder. Also, if the GIBO_BOILERPLATES environment variable is specified, it will be set in the directory pointed to by that variable.

Getting .gitignore Information

To retrieve .gitignore information, use the gibo dump command. For example, for the Go language:

$ gibo dump go
### https://raw.github.com/github/gitignore/218a941be92679ce67d0484547e3e142b2f5f6f0/Go.gitignore

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

You can also specify platforms in addition to programming languages. For instance, by specifying both go and vim:

$ gibo dump go vim
### https://raw.github.com/github/gitignore/218a941be92679ce67d0484547e3e142b2f5f6f0/Go.gitignore

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/


### https://raw.github.com/github/gitignore/218a941be92679ce67d0484547e3e142b2f5f6f0/Global/Vim.gitignore

# Swap
[._]*.s[a-v][a-z]
!*.svg  # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim
Sessionx.vim

# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~

You can do something like that. Well, it's really just concatenating the respective information (lol).

You can save it to a .gitignore file using redirection.

$ gibo dump go vim > .gitignore

You can get a list of names that can be specified with the gibo dump command using the gibo list command (there are so many that I'll skip showing an example).

gibo Command Line Completion

You can add gibo command line completion features on bash, zsh, and fish using the script files in the shell-completions directory of the simonwhitaker/gibo repository.

For example, if you are using bash, you can just drop the gibo-completion.bash file into the /etc/bash_completion.d directory.

References

GitHubで編集を提案

Discussion