| Crates.io | submodule-hook |
| lib.rs | submodule-hook |
| version | 0.1.0 |
| created_at | 2025-12-06 14:27:38.280791+00 |
| updated_at | 2025-12-06 14:27:38.280791+00 |
| description | submodules check pre commit hook |
| homepage | |
| repository | https://github.com/PicoJr/submodule-hook |
| max_upload_size | |
| id | 1970282 |
| size | 60,171 |
This pre-commit hook asks you to confirm when submodules are either:
It looks like this (YMMV) if you configure it as your pre-commit hook:
? The following submodules are modified but not staged for commit:
* sub2 (`git add sub2` to add submodule to staging)
The following submodules are modified and staged for commit:
* sub (`git restore --staged sub` to remove submodule from staging)
Do you wish to continue anyway? (y/n) › no
Build using musl
cargo build --target=x86_64-unknown-linux-musl
and then
❯ ldd target/x86_64-unknown-linux-musl/debug/submodule-hook
statically linked
pre-commit hook ?cargo build --target=x86_64-unknown-linux-musl --releasepre-commit hook: cp target/x86_64-unknown-linux-musl/release/submodule-hook .git/hooks/pre-commitinstall it: cargo install submodule-hook
install it as your pre-commit hook: cp $(which submodule-hook) .git/hooks/pre-commit
Remove the hook using: rm .git/hooks/pre-commit
If you installed it from crates.io, you can remove the binary from your ~/.cargo/bin directory using: cargo uninstall submodule-hook
pre-commit hook ?Yes, you can run it manually:
submodule-hook --repo <path-to-your-repo>
Configuration is evaluated in this order:
~/.gitconfig.git/configcargo run -- --helpstrict = false, staging = true, notstaging = trueEdit local .git/config or global ~/.gitconfig
[submodulehook]
# if true the hook will fail when opening repository or submodule fails
strict = false
# if true also ask for confirmation before commit when a submodule is modified and staged
staging = true
# if true also ask for confirmation before commit when a submodule is modified and not staged
notstaging = true
if both
stagingandnotstagingare set tofalsethen the hook will be disabled
Or use git config:
git config submodulehook.strict false
git config submodulehook.staging true
git config submodulehook.notstaging true
Please see the CHANGELOG for a release history.