Git push safety checker - blocks pushes to forbidden areas
npm install safe-pushA Bun CLI tool for safe Git push operations. Detects changes to forbidden areas (default: .github/) and blocks pushes based on configurable conditions.
``bash`
bun install
bun run build
Global installation:
`bash`
bun link
`bash`
safe-push check # Display result in human-readable format
safe-push check --json # Output result as JSON
`bash`
safe-push push # Check and push if allowed
safe-push push --force # Bypass safety checks
safe-push push --dry-run # Show result without actually pushing
`bash`
safe-push config init # Initialize configuration file
safe-push config init -f # Overwrite existing configuration
safe-push config show # Show current configuration
safe-push config path # Show configuration file path
``
Push Allowed = (No forbidden changes) AND (New branch OR Last commit is yours)
| Forbidden Changes | New Branch | Last Commit Yours | Result |
|-------------------|------------|-------------------|---------|
| No | Yes | - | Allowed |
| No | No | Yes | Allowed |
| No | No | No | Blocked |
| Yes | - | - | Blocked |
Path: ~/.config/safe-push/config.jsonc
`jsonc`
{
// Forbidden paths (glob patterns)
"forbiddenPaths": [".github/"],
// Behavior on forbidden changes: "error" | "prompt"
"onForbidden": "error"
}
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| forbiddenPaths | string[] | [".github/"] | Paths to block changes (glob patterns) |onForbidden
| | "error" \| "prompt" | "error" | Behavior when forbidden changes detected |
- error: Display error and exitprompt
- : Ask user for confirmation
Local email is determined by the following priority:
1. Environment variable SAFE_PUSH_EMAILgit config user.email
2.
`bashRun in development
bun run dev -- check
MIT