Line-level git ignore: strip marked lines and blocks before they enter the repository.
Project description
gitignoreline
Line-level git ignore. Mark individual lines or blocks in any source file with a comment, and they will be automatically stripped before commit — your working copy keeps them, the repository never sees them.
Built on git's native clean/smudge filter mechanism, so it works transparently with git add, git commit, and git diff.
Quick Start
# Install (pick one)
uv tool install gitignoreline # recommended
pip install gitignoreline # or classic pip
# Set up in your repo
cd your-repo
gitignoreline init
Now mark lines in your code:
host = "localhost"
api_key = "sk-secret-key-12345" # gitignore
port = 8080
When you git add and git commit, the api_key line is silently removed from the committed file. Your working copy stays unchanged.
How It Works
Working Copy (yours) Git Repository (shared)
───────────────────── ──────────────────────
host = "localhost" host = "localhost"
api_key = "sk-..." # gi (line removed)
port = 8080 port = 8080
gitignoreline initregisters a clean filter in.git/configand writes patterns to.gitattributes.- Whenever git stages a file, the clean filter reads it, strips all marked lines/blocks, and passes the sanitised version to git.
- The smudge filter is a pass-through (
cat), so checkouts are untouched. - Your working copy is never modified — secrets stay local.
Marker Syntax
Single Line
Append the gitignore marker as a comment at the end of the line:
secret = "value" # gitignore
const key = "abc123"; // gitignore
.secret { display: none; } /* gitignore */
INSERT INTO keys VALUES ('sk-123'); -- gitignore
Block
Wrap multiple lines between start/end markers:
# gitignore-start
AWS_ACCESS_KEY = "AKIA..."
AWS_SECRET_KEY = "wJalr..."
# gitignore-end
// gitignore-start
const config = {
apiKey: "secret",
apiSecret: "also-secret",
};
// gitignore-end
Both the marker lines and everything between them are removed from the committed file.
Supported Comment Styles
The comment style is auto-detected from the file extension:
| Style | Extensions |
|---|---|
# gitignore |
.py, .sh, .yaml, .yml, .toml, .rb, .env, .dockerfile, ... |
// gitignore |
.js, .ts, .tsx, .jsx, .c, .cpp, .java, .go, .rs, .cs, .swift, .kt, ... |
-- gitignore |
.sql, .lua, .hs, .elm, .ada |
% gitignore |
.tex, .m, .erl |
<!-- gitignore --> |
.html, .xml, .svg, .md, .vue |
/* gitignore */ |
.css, .scss, .sass, .less |
; gitignore |
.ini, .asm, .clj, .lisp |
Custom extensions can be added via a .gitignoreline config file.
CLI Commands
| Command | Description |
|---|---|
gitignoreline init |
Set up filters and .gitattributes in the current repo |
gitignoreline status |
Show files and lines with gitignore markers |
gitignoreline check |
Verify no markers leaked into staged content (pre-commit hook) |
gitignoreline ci-check |
Verify no markers in committed content (CI pipeline) |
gitignoreline install-hooks |
Install a git pre-commit hook |
gitignoreline save |
Backup marked lines to .gitignoreline.local |
gitignoreline restore |
Restore marked lines from .gitignoreline.local |
gitignoreline init
gitignoreline init # Enable for all known extensions
gitignoreline init -e .py -e .js # Enable only for specific extensions
gitignoreline init --write-config # Also create a .gitignoreline config template
gitignoreline check / gitignoreline ci-check
gitignoreline check # Check staged content (pre-commit)
gitignoreline ci-check # Check committed content at HEAD (CI)
gitignoreline ci-check --ref main # Check a specific ref
gitignoreline install-hooks
gitignoreline install-hooks # Writes .git/hooks/pre-commit
gitignoreline save / gitignoreline restore
gitignoreline save # Snapshot marked lines to .gitignoreline.local
gitignoreline restore # Re-inject lines from .gitignoreline.local
Enforcing in Teams & Open Source
See quickstart.md for a full enforcement guide. The short version:
- Local hooks —
gitignoreline install-hooksor use the pre-commit framework:
# .pre-commit-config.yaml
repos:
- repo: https://github.com/h3ll5ur7er/gitignoreline
rev: v0.1.0
hooks:
- id: gitignoreline-check
- CI gate — add
gitignoreline ci-checkto your pipeline:
# .github/workflows/gitignoreline.yml
- run: pip install gitignoreline && gitignoreline ci-check
- Branch protection — mark the CI job as a required status check.
Configuration
Create a .gitignoreline file (TOML) in the repository root:
# Map custom extensions to comment styles: [prefix, suffix]
[extensions]
".vue" = ["<!--", "-->"]
".custom" = ["//"]
# Limit which extensions get filter patterns in .gitattributes
[filter]
extensions = [".py", ".js", ".ts", ".yaml"]
Installation
From PyPI
uv tool install gitignoreline # recommended
pip install gitignoreline # classic pip
pipx install gitignoreline # or pipx
From source
git clone https://github.com/h3ll5ur7er/gitignoreline.git
cd gitignoreline
uv tool install .
Development
git clone https://github.com/h3ll5ur7er/gitignoreline.git
cd gitignoreline
uv sync
uv run pytest -v
Important Notes
- Fresh clones won't have the marked lines — they were never committed. Developers add their own local values, or use
gitignoreline restorefrom a shared.gitignoreline.local. - Each developer must run
gitignoreline initonce per clone to register the filter locally. - The
.gitattributesfile should be committed so the project declares which files use the filter. - The
.gitignoreline.localstore file should not be committed (added to.gitignoreautomatically).
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gitignoreline-0.1.0.tar.gz.
File metadata
- Download URL: gitignoreline-0.1.0.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc9407dd0bd1199de43f1e433d8c53a8ad22ef7f61c767e026d7b9f5a55aea6a
|
|
| MD5 |
56a36ed690d4096e9fd1eeb6966240a8
|
|
| BLAKE2b-256 |
74ac077ebaacd2decbb678f3a22218388e9c5f6e91beb2e054c13f5b0bc2ee47
|
Provenance
The following attestation bundles were made for gitignoreline-0.1.0.tar.gz:
Publisher:
release.yml on h3ll5ur7er/gitignoreline
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gitignoreline-0.1.0.tar.gz -
Subject digest:
fc9407dd0bd1199de43f1e433d8c53a8ad22ef7f61c767e026d7b9f5a55aea6a - Sigstore transparency entry: 1076877821
- Sigstore integration time:
-
Permalink:
h3ll5ur7er/gitignoreline@ba7dc66c03b02cf76265539a7ee9e52927584ffd -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/h3ll5ur7er
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ba7dc66c03b02cf76265539a7ee9e52927584ffd -
Trigger Event:
push
-
Statement type:
File details
Details for the file gitignoreline-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gitignoreline-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
332e737e4adbbe2e8a6a2147baf05d953e29e3c2b41e905e336d7fef2df1caaf
|
|
| MD5 |
45c23b6d0b6e875a00a0d83eb47db08a
|
|
| BLAKE2b-256 |
29253cd7bdd366ebb0a1365989b158b7ce527117979f8e244bcfeb9f2fec62e3
|
Provenance
The following attestation bundles were made for gitignoreline-0.1.0-py3-none-any.whl:
Publisher:
release.yml on h3ll5ur7er/gitignoreline
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gitignoreline-0.1.0-py3-none-any.whl -
Subject digest:
332e737e4adbbe2e8a6a2147baf05d953e29e3c2b41e905e336d7fef2df1caaf - Sigstore transparency entry: 1076877833
- Sigstore integration time:
-
Permalink:
h3ll5ur7er/gitignoreline@ba7dc66c03b02cf76265539a7ee9e52927584ffd -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/h3ll5ur7er
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ba7dc66c03b02cf76265539a7ee9e52927584ffd -
Trigger Event:
push
-
Statement type: