Skip to content

EspressoGuardian/shell-guard

shell-guard 🛡️

Additional Git safety hooks.

shell-guard is a lightweight bash utility designed to protect your repository from accidental commits during "dirty" states. It ensures that critical operations—like releases or merges—only proceed when your working directory is clean, or after a safety snapshot has been taken.

Features

  • Deterministic: Validates your git state before you execute irreversible commands.
  • Safety Snapshots: Automatically archives diffs and untracked files into .guardian/snapshots/ if you're working in a dirty repo.
  • CI-Ready: Returns standard exit codes for easy integration into build pipelines.

Installation

  1. Drop shell-guard.sh into your project's bin/ or scripts/ folder.
  2. Grant execution permissions: chmod +x shell-guard.sh.

Usage

Halt if repo is dirty:

./shell-guard.sh --check || exit 1

Force a state snapshot:

./shell-guard.sh --snapshot

Principles

  • Fail-Fast: Catch configuration and state drift before it enters your history.
  • Risk-Averse: Designed to prioritize data safety by observing and archiving state rather than modifying it.
  • Zero Dependencies: Pure bash. Works everywhere git does.

Safety & Support

This is a small tool I built for my own workflow and I’m sharing it in case it helps others.

  • Tested on: Linux (TUXEDO OS)
  • Other platforms: may work, but not regularly tested
  • Transparency: Source code is heavily commented to explain logic and known limitations.

Please review scripts before running, and try them on non-critical data first.

License

MIT

About

Git safety hooks for the paranoid

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages