chegi hooks¶
Manage Git hooks with automatic guard scanning.
Synopsis¶
chegi hooks install [OPTIONS]
chegi hooks remove [OPTIONS]
chegi hooks status [OPTIONS]
Description¶
chegi hooks installs Git hooks that automatically run chegi guard before commits or pushes.
Two hook types are supported:
- Pre-commit (default) — runs
chegi guard --fixbefore everygit commit. Sensitive files are auto-unstaged and the commit is aborted. - Pre-push (
--pre-push) — runschegi guard --fixon staged files andchegi guard --scan .on unpushed commits before everygit push. The push is aborted if sensitive data is found.
This prevents accidental commits or pushes of passwords, keys, .env files, and other sensitive data even when you forget to run chegi guard manually.
install¶
Installs a Git hook that runs chegi guard at the appropriate stage.
- Creates
.git/hooks/pre-commitor.git/hooks/pre-pushwith the guard script - The hook is made executable
- If a hook already exists, the command fails unless
--forceis used - Only hooks containing the cheGi marker are considered "cheGi hooks"
remove¶
Removes the cheGi Git hook.
- Only removes hooks previously installed by
chegi hooks install - Custom hooks (not installed by cheGi) are left untouched
- Safe to run even when no hook is installed (exits with a message)
status¶
Reports whether the cheGi hook is installed and shows the file path.
Options¶
install¶
| Option | Short | Description | Default |
|---|---|---|---|
--path |
-p |
Path to the Git repository | . |
--force |
-f |
Overwrite existing hook | False |
--pre-push |
Install a pre-push hook instead of pre-commit | False |
remove¶
| Option | Short | Description | Default |
|---|---|---|---|
--path |
-p |
Path to the Git repository | . |
--pre-push |
Remove a pre-push hook instead of pre-commit | False |
status¶
| Option | Short | Description | Default |
|---|---|---|---|
--path |
-p |
Path to the Git repository | . |
--pre-push |
Check pre-push hook status instead of pre-commit | False |
Examples¶
Install the pre-commit guard hook:
chegi hooks install
Install the pre-push guard hook:
chegi hooks install --pre-push
Install in a specific project with force:
chegi hooks install -p ~/projects/my-app --force
Check status of pre-push hook:
chegi hooks status --pre-push
Remove the pre-push hook:
chegi hooks remove --pre-push