LinuxCommandLibrary

git-ignore

Exclude files from Git repository tracking

TLDR

Show the content of all global and local .gitignore files

$ git ignore
copy

Ignore file(s) privately, updating .git/info/exclude file
$ git ignore [file_pattern] --private
copy

Ignore file(s) locally, updating local .gitignore file
$ git ignore [file_pattern]
copy

Ignore file(s) globally, updating global .gitignore file
$ git ignore [file_pattern] --global
copy

SYNOPSIS

git-ignore ...

PARAMETERS


    The name of the `.gitignore` template to use. Multiple template names can be specified, separated by spaces. Examples: `Python`, `Node`, `VisualStudio`.

DESCRIPTION

The `git-ignore` command is a tool that helps you generate `.gitignore` files for your projects. A `.gitignore` file specifies intentionally untracked files that Git should ignore. This prevents accidental committing of irrelevant or sensitive files like build artifacts, temporary files, or editor-specific configuration files. By using `git-ignore`, you can easily create or update `.gitignore` files based on templates specific to your project's technology stack (e.g., Python, Java, Node.js) or IDE (e.g., IntelliJ, VS Code). This can significantly improve the cleanliness of your Git repository and prevent unnecessary bloat. It leverages the ignore.io service which provides a comprehensive and up-to-date collection of `.gitignore` templates. It's crucial for maintaining a clean and efficient version control system. The command typically interacts with an external service to retrieve these templates. Proper use of `.gitignore` files is a best practice for all Git repositories.
Note: The `git-ignore` command is not a standard Git command and requires a third-party installation.

CAVEATS

Requires a third-party tool installation (e.g., using npm: `npm install -g gitignore-cli`). The quality of the generated `.gitignore` file depends on the quality and completeness of the templates available at ignore.io. Internet access is typically required to download the templates.

USAGE EXAMPLES

1. Create a `.gitignore` file for a Python project:
git-ignore Python

2. Create a `.gitignore` file for a Node.js and Visual Studio project:
git-ignore Node VisualStudio

3. Appending to an existing `.gitignore` file:
If a `.gitignore` file already exists, the command usually appends the new template content to the existing file.

INSTALLATION

The `git-ignore` command is often provided by a third-party tool. A common installation method involves using Node Package Manager (npm): npm install -g gitignore-cli. Please consult the specific documentation for the `git-ignore` tool you're using for the correct installation instructions.

SEE ALSO

git(1), git-add(1), git-rm(1), git-status(1)

Copied to clipboard