Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/r4ai/git-ignore
A git subcommand to generate .gitignore files.
https://github.com/r4ai/git-ignore
git gitignore gitignore-cli gitignore-generator rust
Last synced: 20 days ago
JSON representation
A git subcommand to generate .gitignore files.
- Host: GitHub
- URL: https://github.com/r4ai/git-ignore
- Owner: r4ai
- License: mit
- Created: 2023-10-19T12:28:40.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-10T08:22:08.000Z (9 months ago)
- Last Synced: 2024-04-20T08:51:18.542Z (9 months ago)
- Topics: git, gitignore, gitignore-cli, gitignore-generator, rust
- Language: Rust
- Homepage:
- Size: 1.93 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
git-ignore
A git subcommand to generate .gitignore files.
## Features
- Generate .gitignore based on the contents of the local directory. (by default, the contents of [github/gitignore](https://github.com/github/gitignore) are used)
- Completion in Fish, Bash, Zsh
- Works on Linux, Windows, MacOS## Installation
Install `git-ignore` with cargo:
```sh
cargo install git-ignore --git https://github.com/r4ai/git-ignore
```And then, register it as a subcommand of git:
```sh
sudo git-ignore --register
```## Usage
Generate a .gitignore file for Rust:
```sh
git ignore rust > .gitignore
```Generate a .gitignore file for Rust, Python, and C++:
```sh
git ignore rust python c++ > .gitignore
```## Completion
### Fish shell
Add the following line to your `~/.config/fish/config.fish`:
```sh
test -e (git --exec-path)/git-ignore; and source (git ignore --completion fish | psub)
```This will enable completion for `git ignore` subcommand.
### Bash
Add the following line to your `~/.bashrc`:
```sh
if [ -f "$(git --exec-path)/git-ignore" ]; then
source <(git ignore --completion bash)
fi
```This will enable completion for `git ignore` subcommand.
### Zsh
Run the following command:
```sh
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`:
>
> ```sh
> fpath=(~/.zsh/completions $fpath)
> ```## Configuration
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](https://github.com/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.
```sh
git config --global ignore.path /path/to/your/gitignore
```For example, if you want to use [toptal/gitignore](https://github.com/toptal/gitignore/) instead of [github/gitignore](https://github.com/github/gitignore), simply clone [toptal/gitignore](https://github.com/toptal/gitignore/) to `/home/alice/.local/share/gitignore`:
```sh
$ git ignore --repo
/home/alice/.local/share/gitignore$ cd /home/alice/.local/share
$ rm -rf ./gitignore
$ gh repo clone toptal/gitignore
```
## Development
Clone repository:
```sh
gh repo clone r4ai/git-ignore
```Build and install `git-ignore` from local repositories.
```sh
cargo install --path .
```Register it as a subcommand of git:
```sh
git-ignore --register
```## LICENSE
MIT License