Skip to main content

ign

A tool for composing and synchronizing .gitignore from GitHub’s template collection.

Description

ign automatically manages .gitignore files by synchronizing them with templates from GitHub’s gitignore repository. It intelligently merges your local modifications with upstream template changes, preserving your customizations while keeping templates up to date.

Key Features

  • Template synchronization: Automatically update .gitignore templates from GitHub

  • Local modification preservation: Keeps your custom additions while updating templates

  • Intelligent merging: Uses diff/patch algorithms to resolve conflicts

  • Multiple merge strategies: Tries different approaches to apply changes safely

  • Auto-detection: Automatically detects existing templates in your .gitignore

  • Flexible input/output: Works with files or stdin/stdout

  • Dry-run mode: Preview changes before applying them

Installation

Using uv:

uv add ign

Using pip:

pip install ign

Usage

Basic Usage

Add templates to your .gitignore:

ign Python Node

Update existing templates:

ign

Sync specific templates with version pinning:

ign Python@main Node@abc1234

Command Line Options

ign [OPTIONS] [TEMPLATE[@HASH]...]

Options:

-f, --file FILE

Input .gitignore file (default: .gitignore, - for stdin)

-o, --output FILE

Output file (default: same as input, - for stdout)

-d, --diff

Show unified diff of changes

-n, --dry-run

Preview changes without writing

-v, --verbose

Verbose output: enable debug logging

-q, --quiet

Quiet output: only show errors and warnings

--logging TYPE

Logging format: console or json (default: console if TTY, otherwise JSON)

--debug

All-debug output: enable debug logging on all libraries

--version

Show version and exit

Arguments:

TEMPLATE[@HASH] GitHub template names (without .gitignore extension)

Optional @HASH pins to specific commit

Examples

Add Python and Node.js templates:

ign Python Node

Update all existing templates:

ign

Preview changes without applying:

ign --dry-run --diff

Use with custom file:

ign --file my-project/.gitignore Java Maven

Read from stdin, write to stdout:

cat .gitignore | ign -f- Python > new-gitignore

Pin template to specific version:

ign Python@4f15b43 Node@latest

How It Works

Template Markers

ign uses special marker comments to track template sections:

# --- BEGIN https://raw.githubusercontent.com/github/gitignore/{SHA}/{TEMPLATE}.gitignore ---
# Template content here
# --- END https://raw.githubusercontent.com/github/gitignore/{SHA}/{TEMPLATE}.gitignore ---

These markers allow ign to:

  • Identify which templates are already included

  • Track the version (SHA) of each template

  • Preserve local modifications between updates

Merge Strategy

When updating templates, ign uses a sophisticated merge algorithm:

  1. Fetch versions: Downloads both old (current) and new (latest) template versions

  2. Apply strategies: Tries two different merge approaches:

    • Strategy A: Apply (new - old) changes to your local modifications

    • Strategy B: Apply (local - old) changes to the new template

  3. Conflict resolution: Falls back gracefully when automatic merging fails

  4. Preserve customizations: Your local additions are always preserved

Local Modifications

You can safely add custom rules within template sections. For example:

# --- BEGIN https://raw.githubusercontent.com/github/gitignore/.../Python.gitignore ---
# Original Python template content...

# Your custom additions
*.local
/my-project-specific-file

# --- END https://raw.githubusercontent.com/github/gitignore/.../Python.gitignore ---

These modifications will be preserved during template updates.

Configuration

Environment Variables

GITHUB_API_TOKEN

Optional GitHub API token for higher rate limits. Useful for heavy usage or when working with private repositories.

Example .env file:

GITHUB_API_TOKEN=ghp_your_token_here

Template Sources

Templates are fetched from the official GitHub gitignore repository. Available templates include:

  • Languages: Python, Java, JavaScript, Go, Rust, C++, etc.

  • Frameworks: Node, Django, Rails, Laravel, etc.

  • Tools: JetBrains, VisualStudio, Vim, macOS, Windows, etc.

  • Platforms: Android, iOS, Unity, etc.

For a complete list, visit: https://github.com/github/gitignore

Troubleshooting

Common Issues

Template not found

Ensure the template name matches exactly (case-sensitive) with files in the GitHub repository. Check https://github.com/github/gitignore for available templates.

Merge conflicts

If automatic merging fails, ign will preserve your current content and log the issue. You may need to manually resolve conflicts.

API rate limits

Set GITHUB_API_TOKEN environment variable to increase rate limits.

Missing END marker

If you manually edit marker comments, ensure BEGIN/END pairs match exactly. Use --debug for detailed error information.

Debug Mode

Enable debug logging for detailed information:

ign --debug --verbose Python

This shows:

  • Template fetching details

  • Merge strategy decisions

  • Diff application results

  • API request information

Development

Setting up development environment:

git clone https://github.com/astralblue/ign.git
cd ign
uv sync

Running tests:

pytest

Code formatting:

ruff check --fix && ruff format

Building documentation:

cd docs
make html

License

MIT License. See LICENSE file for details.

Contributing

Contributions are welcome! Please:

  1. Fork the repository

  2. Create a feature branch

  3. Add tests for new functionality

  4. Run the test suite and linting

  5. Submit a pull request

For bug reports and feature requests, please use the GitHub issue tracker.

Metadata

Release files for ign 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ign 0.1.1
File Size Uploaded Provenance
ign-0.1.1.tar.gz 75.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ign 0.1.1
File Interpreter ABI Platform
ign-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 86.2 kB

Release files / ign-0.1.1.tar.gz

Download URL ign-0.1.1.tar.gz
Size 75.9 kB
Tags Source
SHA-256 checksum
How to use checksums
adfd8c3312b7ae1c5f7ae5a50ea7bfbb846675b0faab6b31e5021d3ae9ac0b75
BLAKE2b-256 checksum
How to use checksums
444db94a1c29ad5a4085dc0284eafe4ccbba81c3da98307f5a3bcf345107b855
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.4

Release files / ign-0.1.1-py3-none-any.whl

Download URL ign-0.1.1-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56933e26a44b9ba9d13e92ce7a65766e922c017fa0f284b633a08b6142987a0b
BLAKE2b-256 checksum
How to use checksums
a32ebd267aa020d693b3e7845bcefec6dbb58ddcc97d46b34eca3b502eb5dd86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.4

Security for ign 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page