git-conventions
1.0.0
dotnet add package git-conventions --version 1.0.0
NuGet\Install-Package git-conventions -Version 1.0.0
<PackageReference Include="git-conventions" Version="1.0.0" />
<PackageVersion Include="git-conventions" Version="1.0.0" />
<PackageReference Include="git-conventions" />
paket add git-conventions --version 1.0.0
#r "nuget: git-conventions, 1.0.0"
#:package git-conventions@1.0.0
#addin nuget:?package=git-conventions&version=1.0.0
#tool nuget:?package=git-conventions&version=1.0.0
Conte.GitConventions
Conte.GitConventions is a small .NET 8 CLI that installs and maintains native Git enforcement for branch names and Conventional Commits.
It uses only Git's built-in capabilities:
core.hooksPathcommit.template- native hooks such as
commit-msgandpre-push
There is no Node.js, Husky, commitlint, Python package, or third-party hook framework involved.
Why Native Git Only
This project enforces conventions at the Git layer, which means the behavior is shared by:
- Visual Studio
- VS Code
- command-line Git
- any Git-aware editor or workflow that respects Git configuration
Because enforcement lives in Git itself, teams do not need editor-specific extensions or per-repo JavaScript tooling just to keep branch names and commit messages consistent.
Managed Behavior
The tool manages a dedicated folder under the current user's home directory:
- Windows example:
%USERPROFILE%\.conte-git-conventions - Linux/macOS design target:
~/.conte-git-conventions
Inside that folder it manages:
hooks/commit-msghooks/pre-pushscripts/commit-msg.ps1scripts/pre-push.ps1templates/commit-template.txt
Every managed file contains an internal marker with a version number. That marker is used to:
- detect whether a file belongs to this tool
- report drift during
status - safely repair only tool-managed files
- avoid deleting unrelated user files during
uninstall
Commands
Build and run locally:
dotnet build Conte.GitConventions.sln
dotnet run --project .\src\Conte.GitConventions.Tool -- install
dotnet run --project .\src\Conte.GitConventions.Tool -- status
dotnet run --project .\src\Conte.GitConventions.Tool -- repair
dotnet run --project .\src\Conte.GitConventions.Tool -- uninstall
CLI contract:
git-conventions install
git-conventions status
git-conventions repair
git-conventions uninstall
What install Does
install will:
- Verify Git is installed.
- Create the managed folder structure if it does not exist.
- Write the managed hook wrappers and PowerShell scripts.
- Write the default commit message template.
- Configure:
git config --global core.hooksPath <managed-hooks-path>git config --global commit.template <managed-template-path>
- Leave unrelated files untouched.
- Behave idempotently when run multiple times.
What status Checks
status reports:
- Git installed: yes/no
core.hooksPathconfigured: yes/nocommit.templateconfigured: yes/no- managed files present: yes/no
- hook content valid: yes/no
- overall health: healthy/warning/error
It also explains what is missing, outdated, or conflicting.
What repair Does
repair restores the expected managed state:
- re-creates missing managed files
- overwrites invalid or outdated tool-managed files
- restores Git global configuration if it drifted away from the expected managed paths
It still refuses to overwrite unmanaged files.
What uninstall Does
uninstall removes only what this tool owns:
- deletes managed files that still contain the tool marker
- removes empty managed directories
- unsets
core.hooksPathonly if it still points to the tool-managed hooks path - unsets
commit.templateonly if it still points to the tool-managed template path
It will not delete unrelated custom hooks or unrelated Git configuration.
Conventions Enforced
Branch Names
Accepted examples:
feat/exchange-rate-syncfix/login-timeoutdocs/readme-updaterefactor/task-configtest/scheduler-ruleschore/repo-cleanuphotfix/sql-timeout
Regex:
^(feat|fix|docs|refactor|test|chore|hotfix)\/[a-z0-9._-]+$
Conventional Commits
Accepted examples:
feat(api): add exchange rate syncfix(auth): handle expired cookierefactor(scheduler): simplify next-run calculationchore(repo): update git hooks
Regex:
^(feat|fix|docs|style|refactor|test|chore|build|ci|perf)(\([a-z0-9._-]+\))?!?: .+$
How the Hooks Work
The hooks folder contains the files Git expects:
commit-msgpre-push
On Windows-first installations, those hooks are small shell wrappers that invoke tool-managed PowerShell scripts:
scripts/commit-msg.ps1scripts/pre-push.ps1
commit-msg.ps1 validates the first real commit-message line against the Conventional Commits regex.
pre-push.ps1 validates the current branch name against the branch regex before the push proceeds.
This approach keeps enforcement native to Git while letting the project author the logic entirely with .NET-generated content.
Why Visual Studio and VS Code Benefit
Because the rules are enforced by Git itself:
- Visual Studio commits are checked by
commit-msg - VS Code source control commits are checked by
commit-msg - pushes from terminals, IDEs, and GUI Git clients are checked by
pre-push
That keeps behavior consistent across tools without requiring editor-specific extensions.
Safety Notes
- The tool writes only to its own managed folder.
- It uses an internal marker to distinguish managed files from user files.
- It does not automatically overwrite unrelated existing files.
- It does not unset unrelated Git configuration values.
- It is safe to run
installmultiple times.
Limitations
- Windows is the primary target in this version.
- The generated hook wrappers call PowerShell scripts, so non-Windows environments are designed for future support rather than fully optimized today.
- The
pre-pushhook validates the current local branch name. Detached HEAD workflows are intentionally rejected.
Future Improvements
- add first-class Linux and macOS script generation
- package as a global .NET tool
- support team-specific convention profiles
- add a minimal test project around orchestration behavior if the codebase grows
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Conte.GitConventions.Core (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|