Skip to content

About

CLI that keeps a repo's .gitignore maintained — curated blocks inside a managed region, re-rendered idempotently, nothing outside it touched.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

139 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧰 gitignore-sync

Keeps your .gitignore maintained, not generated — curated blocks in a region the tool owns, everything else untouched

Release crates.io npm Version Downloads Tests License: MIT


gis init     # fingerprint the repo, confirm, write the region
gis sync     # re-render it, any time, as often as you like

That's it — gis is the short name of gitignore-sync, one native binary with no runtime. The blocks the tool owns stay current; every line you wrote yourself survives verbatim.

🤔 Why

gitignore.io, gig and ignr all fetch and dump: you pull a template once, paste it, and drift from there. None of them re-syncs, so a .gitignore grows into a few hundred lines of ballast nobody dares touch.

gitignore-sync keeps a managed region inside the file and re-renders it on demand. The rest of the file is a free zone the tool never writes to — which is what makes running it a second time safe, and a hundredth time boring.

📦 Installation

On Linux and macOS:

(set -e; d="$(mktemp -d)"; trap 'rm -rf -- "${d:?}"' EXIT; cd "${d:?}"
  curl -fsSLO https://raw.githubusercontent.com/kirchDev/gitignore-sync/v0.7.2/install.sh
  sh install.sh)

It installs gitignore-sync and the short name gis into ~/.local/bin, after checking the archive's SHA-256 and its signature. It never runs sudo; --dir picks another directory, --version another release. Afterwards gitignore-sync self-update keeps it current. The native binary and install.sh ship from v0.7.0 on.

What the installer checks, and how to check the script before it runs

The installer checks the archive's signature against the release key (with minisign, or gh attestation verify without it; --skip-signature settles for the SHA-256 alone and says so). The install command downloads the script whole into a private directory of its own, removed afterwards, before it runs: a cut-off transfer runs nothing, and no file of yours is overwritten.

That command takes install.sh from the release tag in this repository. To verify the script itself first, check it against the release key — in a private directory again, and only a signature whose signed comment names this release's install.sh counts:

(set -e; d="$(mktemp -d)"; trap 'rm -rf -- "${d:?}"' EXIT; cd "${d:?}"
  curl -fsSLO https://github.com/kirchDev/gitignore-sync/releases/download/v0.7.2/install.sh
  curl -fsSLO https://github.com/kirchDev/gitignore-sync/releases/download/v0.7.2/install.sh.sig
  minisign -V -P RWR284tUOD7ful9WRVyLZ1vJNvk0zHSURT4Rv49z/infgx48VXYvZn9C -m install.sh -x install.sh.sig | grep -Fq 'tag=v0.7.2 file=install.sh '
  sh install.sh --dir "$HOME/.local/bin")

The key is also in minisign.pub. Every archive and SHA256SUMS carry a signature too, whose trusted comment names the release tag, the file and its SHA-256.

With Rust, or through npm:

cargo binstall --only-signed gitignore-sync   # the signed release binary; or: cargo install --locked gitignore-sync
pnpm add -g @kirchdev/gitignore-sync          # npm i -g / yarn global add / bun add -g all work

Or run it without installing: npx @kirchdev/gitignore-sync <command>. Windows has no binary. cargo puts only gitignore-sync on the PATH; the installer and npm add the short name gis beside it.

Tip

The macOS binaries are signed ad hoc, not notarised. Installed with curl as above they run as they are; one downloaded in a browser is quarantined first — clear it with xattr -d com.apple.quarantine gitignore-sync.

🚀 Quick start

gitignore-sync init             # detect, confirm in a prompt, write the region
gitignore-sync edit             # tick stacks on and off later
gitignore-sync add nuxt tauri   # or name them — for scripts and CI
gitignore-sync remove intellij  # drop one; your own lines are kept
gitignore-sync sync             # re-render from the header
gitignore-sync check            # CI gate: non-zero on drift
gitignore-sync list             # what this binary ships, and what you declare
gitignore-sync info             # which build is running, and what it sees
gitignore-sync audit ../*/      # how much of a whole estate the stacks cover
gitignore-sync check -r         # every managed region in the tree, not just the root
gitignore-sync self-update      # update the way it was installed, never with sudo
gitignore-sync self-update --check   # only say whether a newer release exists
gitignore-sync self-update --print   # only print the command that would update

Every command takes --help. Every command on a .gitignore — all but self-update — takes a directory (--dir for add/remove, positional elsewhere), and every one of them that writes takes --dry-run.

Tip

init shows everything it found — your editor and platform included — and asks once:

ℹ Found 8 stacks: core, git, node, nuxt, tauri, dotenv, vscode, linux
? Use them? › Yes / No

In CI it asks nothing — --yes or no terminal takes the committed fingerprints alone, says what it skipped, and writes. Your platform must not end up in a committed header because a pipeline ran.

✨ Features

  • 🔁 Re-syncs, never re-dumps — sync is idempotent, so it belongs in a habit, a hook or a cron, not in a one-off ritual.
  • 🛡️ Your lines are never lost — a hand-written line found inside a managed block is moved to the free zone, not deleted. That rule is what makes the second run safe.
  • 🔍 Dedup that knows git — exact duplicates go; .idea, .idea/, /.idea and .idea/* are four different patterns to git, so they are reported, never silently merged.
  • 🧹 Orphaned headings swept — when a managed block absorbs every pattern under a # Comment, the heading goes with them. A block that was only ever a note stays.
  • ⚠️ Catches the mistake that breaks ! — a stray .vscode beside a !.vscode/extensions.json block silently disables it, because git never looks inside an ignored directory. That gets its own warning.
  • 🧭 No surprise rewrites — init detects, sync does not. Adding a package.json never quietly rewrites your .gitignore; sync --detect proposes and stops there.
  • 🗂️ Folds in your editor — the region uses # region / # endregion, so VSCode collapses a 40-line managed block to a single line, at both nesting levels.
  • 📋 A real CI gate — check reports drift and duplicates and exits non-zero, so a stale block fails the build instead of rotting.
  • 📦 One binary, signed — no runtime to install. self-update and the installer replace nothing until the release's signature checks out, and a once-a-day lookup tells you when a newer release exists (off in CI, or with GITIGNORE_SYNC_NO_UPDATE_CHECK=1).

🗂️ The shape

# region gitignore-sync
# stacks: core, node, vscode, intellij
# ─────────────────────────────────────────

# region core@v1
.DS_Store
# endregion

# region node@v1
node_modules
dist
coverage
# endregion

# endregion

# ─── your rules, never touched ───
frankenphp
/bootstrap/ssr

Everything below the closing # endregion is the free zone: yours, preserved line for line.

🧩 Stacks

Curated blocks, each derived from what real repositories actually ignore — or from what the tool writing the files puts in its own scaffold — rather than from a public template site.

Every stack — what it covers and when init proposes it
Stack What it covers Proposed by init when
core .DS_Store always
agents agent working files, not their config .claude/, .codex/, …
git merge and backup droppings always (it is a git repo)
node modules, build output, logs, caches package.json
dotenv .env*, minus the committed example .env.example or .env
php /vendor, auth.json, PHPUnit and PHPStan caches composer.json
laravel build output, storage keys, SSR artisan
octane the server binaries octane:install adds config/octane.php
go test and build droppings go.mod
python __pycache__/, .venv/, tool caches pyproject.toml, requirements.txt, setup.py
tofu state, tfvars, local overrides *.tf / *.tofu
helm vendored chart tarballs Chart.yaml
nuxt .nuxt, .output, .nitro nuxt.config.*
vite dist-ssr, *.local vite.config.* beside index.html
tauri src-tauri/target, generated schemas src-tauri/
rust /target a root Cargo.toml
turborepo .turbo turbo.json
playwright test-results, reports playwright.config.*
storybook storybook-static .storybook/
gradle .gradle/, .kotlin/, build/ build.gradle* / settings.gradle*
vscode .vscode/* + the shared files you have a .vscode/
intellij .idea/* you have a .idea/
vim swap and session files your $EDITOR is vim
macos AppleDouble, Spotlight, Trashes you are on a Mac
windows Thumbs.db, desktop.ini, Recycle Bin you are on Windows
linux *~, trash and NFS droppings you are on Linux

gitignore-sync list prints this for the binary you have installed, marking the ones your repo declares.

⚙️ Configuration

There is no config file. The configuration is the # stacks: line in the .gitignore itself — the header is input, the blocks below it are output.

Edit Effect after sync
Add a name to # stacks: Its block is rendered into the region
Remove a name from # stacks: Its block disappears; your own lines are kept
Nothing Nothing — sync is a no-op on a synced file

Important

Nothing in a repository can tell you what the other contributors use — .vscode/ and .idea/ are themselves ignored. So those stacks are proposed from your own machine and written down once, rather than re-guessed on every run.

🧪 Use in CI

- uses: kirchDev/gitignore-sync@vX.Y.Z
  with:
    version: 'X.Y.Z'   # pin it, so a release cannot turn a green pipeline red

check writes nothing. It exits non-zero when the file has drifted from its header, and prints its findings. The action adds a job summary on failure and a status output. It needs no Node: it runs the release binary, checked against the release's checksums and build attestation on every run, on Linux and macOS runners.

Without the action, any installed copy does the same: gitignore-sync check, or npx @kirchdev/gitignore-sync check on a runner with Node.

Staying on a release before v0.7.0

The action runs releases that ship the native binary, v0.7.0 and later. A workflow that stays on an older version pins the action to that version's tag and the version input together (kirchDev/gitignore-sync@v0.6.0 with version: '0.6.0' runs npx); the old tag alone runs npm's latest.

Note

--recursive on audit and check walks the whole tree, skipping build output, dependencies, nested repositories, and anything the repo's own .gitignore names. Laravel's storage/ stubs and other directory keepers (* plus !.gitignore) are listed as skipped rather than measured — the framework owns them.

Tip

Repos whose CI derives its task list from package.json need neither: add a "check:gitignore": "gitignore-sync check" script and call it from check as pnpm check:gitignore. A bare gitignore-sync check inside check is not enough — kirchDev/workflows' check runs only the named pnpm scripts it finds there, and would skip it.

🤝 Contributing

PRs welcome. The CLI is Rust (the toolchain is pinned in rust-toolchain.toml); Node and pnpm only drive the repo's tooling. pnpm check runs the whole gate — cargo fmt, clippy and the tests included. Conventional Commits are enforced by commitlint, husky runs the formatters on git commit, and pnpm check:fix before pushing saves a CI round. See CONTRIBUTING.md for the full workflow.

🛣️ Versioning

Semantic Versioning via release-please — see CHANGELOG.md.

📄 License

MIT © Titus Kirch / IT-Dienstleistungen Titus Kirch

About

CLI that keeps a repo's .gitignore maintained — curated blocks inside a managed region, re-rendered idempotently, nothing outside it touched.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages

Generated from TitusKirch/scaffold