This directory contains example hook and filter scripts for git-flow-next. Copy the scripts you want to use to your repository's .git/hooks/ directory and make them executable.
# Copy a hook to your repository
cp contrib/hooks/pre-flow-release-start /path/to/repo/.git/hooks/
# Make it executable
chmod +x /path/to/repo/.git/hooks/pre-flow-release-startFilters transform values during git-flow operations:
| Script | Description |
|---|---|
filter-flow-release-start-version |
Validates and normalizes version numbers (adds 'v' prefix) |
filter-flow-release-finish-tag-message |
Appends changelog to tag messages |
Hooks execute before (pre) or after (post) operations:
| Script | Description |
|---|---|
pre-flow-feature-start |
Validates feature branch naming conventions |
pre-flow-release-start |
Checks for uncommitted changes and remote sync |
post-flow-release-finish |
Shows next steps and can trigger notifications |
These are starting points - modify them to fit your workflow:
- CI Integration: Add checks for CI status using
ghor API calls - Notifications: Send Slack/Discord messages on release completion
- Versioning: Enforce your team's version number format
- Naming: Set your own branch naming conventions
- Create a file with the correct name (see patterns below)
- Make it executable:
chmod +x filename - Test it before relying on it
Filters:
filter-flow-{type}-{action}-{target}
type: release, hotfix
action: start, finish
target: version, tag-message
Hooks:
{pre,post}-flow-{type}-{action}
pre/post: when to run
type: feature, release, hotfix, support
action: start, finish, publish, track, delete
All hooks and filters receive context via environment variables:
| Variable | Description |
|---|---|
BRANCH |
Full branch name (e.g., feature/my-feature) |
BRANCH_NAME |
Short name (e.g., my-feature) |
BRANCH_TYPE |
Type (e.g., feature, release) |
BASE_BRANCH |
Parent branch (e.g., develop, main) |
ORIGIN |
Remote name |
VERSION |
Version (for release/hotfix) |
EXIT_CODE |
Post-hooks only: operation result |
To share hooks across your team:
# Option 1: Use Git's core.hooksPath
mkdir .githooks
cp contrib/hooks/* .githooks/
git config core.hooksPath .githooks
# Option 2: Create symbolic links
ln -s ../../.githooks/pre-flow-release-start .git/hooks/For more details, see docs/gitflow-hooks.7.md or run:
git flow hooks --help