Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
petervanderdoes
git-flow-hooks
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
git-flow-hooks
/
prepare-commit-msg
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
44 lines (38 loc) · 1.43 KB
master
Breadcrumbs
git-flow-hooks
/
prepare-commit-msg
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
44 lines (38 loc) · 1.43 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!
/bin/sh
REPO_DIR=
$(
git rev-parse --show-toplevel
)
DOT_GIT_DIR=
$(
git rev-parse --git-dir
)
if
[
"
$DOT_GIT_DIR
"
=
"
.git
"
]
;
then
DOT_GIT_DIR=
"
$REPO_DIR
"
/
"
$DOT_GIT_DIR
"
fi
HOOKS_DIR=
"
$DOT_GIT_DIR
"
/hooks
.
"
$HOOKS_DIR
"
/gitflow-functions
#
#
An example hook script to prepare the commit log message.
#
Called by "git commit" with the name of the file that has the
#
commit message, followed by the description of the commit
#
message's source. The hook's purpose is to edit the commit
#
message file. If the hook fails with a non-zero status,
#
the commit is aborted.
#
#
To enable this hook, rename this file to "prepare-commit-msg".
#
This hook includes three examples. The first comments out the
#
"Conflicts:" part of a merge commit.
#
#
The second includes the output of "git diff --name-status -r"
#
into the message, just before the "git status" output. It is
#
commented because it doesn't cope with --amend or with squashed
#
commits.
#
#
The third example adds a Signed-off-by line to the message, that can
#
still be edited. This is rarely a good idea.
case
"
$2
,
$3
"
in
merge,)
/usr/bin/perl -i.bak -ne
'
s/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print
'
"
$1
"
;;
#
,|template,)
#
/usr/bin/perl -i.bak -pe '
#
print "\n" . `git diff --cached --name-status -r`
#
if /^#/ && $first++ == 0' "$1" ;;
*
) ;;
esac
#
SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
#
grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
You can’t perform that action at this time.