Automatically prepend branch names to your commit messages for better commit tracking and organization.
π Global Installation - Install once and use across all your Git repositories!
Transforms your commit messages by automatically adding the branch name as a prefix:
Before:
git commit -m "initial commit"After (on branch feat/DP-1234):
feat/DP-1234: initial commit
bash <(curl -s https://raw.githubusercontent.com/DappierAI/dappier-githooks/staging/install.sh)iex (iwr -Uri "https://raw.githubusercontent.com/DappierAI/dappier-githooks/staging/install.ps1").Content# Download and run the installer (from any directory)
curl -O https://raw.githubusercontent.com/DappierAI/dappier-githooks/staging/install.sh
chmod +x install.sh
./install.shOr clone and install:
git clone https://github.com/DappierAI/dappier-githooks.git
cd dappier-githooks
chmod +x install.sh
./install.sh# Download and run the installer (from any directory)
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/DappierAI/dappier-githooks/staging/install.ps1" -OutFile "install.ps1"
.\install.ps1Or clone and install:
git clone https://github.com/DappierAI/dappier-githooks.git
cd dappier-githooks
.\install.ps1Now when you commit:
git commit -m "initial commit"On branch feat/DP-1234, it becomes:
feat/DP-1234: initial commit
- Git installed on your system
- macOS/Linux: Bash shell
- Windows: PowerShell and Git for Windows (with Git Bash)
The installer creates a prepare-commit-msg hook in your system's global git hooks directory and configures Git to use it for all repositories. This hook:
- Extracts the current branch name
- Checks if the commit message already has a prefix
- Prepends the branch name to your commit message
- Skips protected branches (dev, dev2, staging, production)
Hook locations:
- macOS:
~/Library/Application Support/Git/hooks/prepare-commit-msg - Linux:
~/.config/git/hooks/prepare-commit-msg - Windows:
%APPDATA%\Git\hooks\prepare-commit-msg
- β Global installation - applies to all repositories on your system
- β Works with all Git clients (VS Code, Fork, GitKraken, command line, etc.)
- β Cross-platform (macOS, Linux, Windows)
- β Prevents double-prefixing
- β Skips merge and squash commits
- β Ignores protected branches
- β No per-repository setup needed
- β Easy to uninstall
# On branch: feat/DP-1234
git commit -m "add user authentication"
# Result: "feat/DP-1234: add user authentication"# On branch: bugfix/DP-5678
git commit -m "fix login redirect issue"
# Result: "bugfix/DP-5678: fix login redirect issue"# On branch: main
git commit -m "update version"
# Result: "update version" (no prefix added)The hook will not add prefixes on these branches:
devdev2stagingproduction
If you prefer to install manually:
mkdir -p "$HOME/Library/Application Support/Git/hooks"
curl -O "$HOME/Library/Application Support/Git/hooks/prepare-commit-msg" https://raw.githubusercontent.com/DappierAI/dappier-githooks/staging/prepare-commit-msg
chmod +x "$HOME/Library/Application Support/Git/hooks/prepare-commit-msg"
git config --global core.hooksPath "$HOME/Library/Application Support/Git/hooks"mkdir -p ~/.config/git/hooks
curl -O ~/.config/git/hooks/prepare-commit-msg https://raw.githubusercontent.com/DappierAI/dappier-githooks/staging/prepare-commit-msg
chmod +x ~/.config/git/hooks/prepare-commit-msg
git config --global core.hooksPath ~/.config/git/hooks$hooksDir = "$env:APPDATA\Git\hooks"
New-Item -ItemType Directory -Path $hooksDir -Force | Out-Null
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/DappierAI/dappier-githooks/staging/prepare-commit-msg" -OutFile "$hooksDir\prepare-commit-msg"
git config --global core.hooksPath $hooksDirTo remove the global git hook:
rm "$HOME/Library/Application Support/Git/hooks/prepare-commit-msg"rm ~/.config/git/hooks/prepare-commit-msgRemove-Item "$env:APPDATA\Git\hooks\prepare-commit-msg"To disable the hooks globally (without removing them):
git config --global --unset core.hooksPathContributions are welcome! Please feel free to submit a Pull Request.
MIT License - feel free to use this in your projects!
- Ensure Git for Windows is installed (includes Git Bash)
- Try running PowerShell as Administrator
- Verify the hook file exists:
%APPDATA%\Git\hooks\prepare-commit-msg - Check git config:
git config --global core.hooksPath
- Verify the hook is executable:
ls -la ~/Library/Application\ Support/Git/hooks/prepare-commit-msg(macOS) orls -la ~/.config/git/hooks/prepare-commit-msg(Linux) - Check git config:
git config --global core.hooksPath - If hook is not executable, make it executable:
chmod +xon the hook file
- Check your current branch:
git branch --show-current - Verify you're not on a protected branch (dev, dev2, staging, production)
- Check if the commit message already has a prefix
- Verify git config is set:
git config --global core.hooksPathshould return your hooks directory
Open an issue on GitHub with:
- Your operating system
- Git version (
git --version) - The branch name you're trying to commit on
- The exact commit command you're using
If you find this useful, please consider giving it a star! β
Made with β€οΈ by the Dappier team