dcg

Strict Git

strict_git

Stricter git protections: blocks force pushes, rebases, history rewriting, blind staging, and direct pushes to default branches

  • 19blocking rules
  • 0safe patterns
  • 19High
~/.config/dcg/config.toml
[packs]
enabled = ["strict_git"]

Evaluated when a command contains git.

Recorded verdicts

  • git rebase -i HEAD~5Blockedstrict_git:rebase

Blocking rules

Each rule ID is strict_git:<name>. Use it in allowlists and [policy.rules].

  1. add-all-dot

    High

    git add . stages everything including secrets, .env files, and build artifacts. Use 'git add <specific-files>' instead.

  2. add-all-flag

    High

    git add -A/--all stages all changes including secrets, .env files, and build artifacts. Use 'git add <specific-files>' instead.

  3. cherry-pick

    High

    git cherry-pick can introduce duplicate commits. Review carefully.

  4. commit-amend

    High

    git commit --amend rewrites the last commit. Disabled in strict mode.

  5. filter-branch

    High

    git filter-branch rewrites entire repository history. Extremely dangerous!

  6. filter-repo

    High

    git filter-repo rewrites repository history. Review carefully.

  7. gc-aggressive

    High

    git gc with aggressive/prune options can remove recoverable objects.

  8. push-delete

    High

    git push --delete removes refs from the remote. Disabled in strict mode.

  9. push-delete-refspec

    High

    git push <remote> :<ref> (empty source) deletes the ref from the remote. Disabled in strict mode.

  10. push-dynamic-argument

    High

    Force push risk: a shell-expanded or escaped git push argument cannot be verified as non-forcing. Use literal remote and refspec arguments in strict mode.

  11. push-force-any

    High

    Force push (even with --force-with-lease) can rewrite remote history. Disabled in strict mode.

  12. push-main

    High

    Direct push to main is blocked. Use a feature branch and open a Pull Request.

  13. push-master

    High

    Direct push to master is blocked. Use a feature branch and open a Pull Request.

  14. push-mirror

    High

    git push --mirror force-updates and deletes remote refs. Disabled in strict mode.

  15. push-prune

    High

    git push --prune deletes remote refs that have no local counterpart. Disabled in strict mode.

  16. rebase

    High

    git rebase rewrites commit history. Disabled in strict mode.

  17. reflog-expire

    High

    git reflog expire removes reflog entries needed for recovery.

  18. submodule-deinit

    High

    git submodule deinit removes submodule configuration.

  19. worktree-remove

    High

    git worktree remove deletes a linked working tree.