git-blocker
v1.0.1
Published
Protect important files from accidental Git commits.
Readme
Git Blocker
Protect important files from accidental Git commits.
Git Blocker is a lightweight Git CLI that warns you before committing files you've marked as protected. Rules are stored locally inside your Git repository, so each developer can maintain their own protected files without affecting teammates.
Features
- Protect files or glob patterns
- Local configuration (stored in
.git/git-blocker/) - Interactive confirmation before committing protected files
- No project files added to your repository
- Simple CLI
- Fast and dependency-light
Installation
From npm
npm install -g git-blockerVerify
git blocker --helpQuick Start
Inside a Git repository:
git blocker installProtect a file:
git blocker add src/admin/config.ts --reason "Temporary testing"Protect a directory:
git blocker add "backend/admin/**" --reason "Critical APIs"List all rules:
git blocker listRemove a rule:
git blocker remove "backend/admin/**"Uninstall Git Blocker:
git blocker uninstallExample
If a protected file is staged:
Git Blocker
• src/admin/config.ts
Reason: Temporary testing
Continue with commit? (y/N)Choosing No aborts the commit.
Choosing Yes allows the commit to continue.
Configuration
Rules are stored locally in:
.git/git-blocker/config.jsonThis file is not committed to Git, allowing each developer to maintain independent protection rules.
Commands
| Command | Description |
| ------------------------------ | ----------------------------------------------- |
| git blocker install | Install Git Blocker into the current repository |
| git blocker uninstall | Remove Git Blocker from the current repository |
| git blocker add <pattern> | Add a protected file or glob pattern |
| git blocker remove <pattern> | Remove a protected rule |
| git blocker list | List configured rules |
| git blocker check | Check staged files manually |
Requirements
- Git
- Node.js 18+
Current Limitations
- v1 replaces an existing
pre-commithook instead of integrating with other hook managers. - Integration with Husky and similar tools is planned for a future release.
License
MIT
