Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Git Hooks: How to Make Friends
Search
Joseph Hsu
April 14, 2012
Programming
5
690
Git Hooks: How to Make Friends
Joseph Hsu
April 14, 2012
Tweet
Share
More Decks by Joseph Hsu
See All by Joseph Hsu
Ruby 2.0
jhsu
3
210
API Versioning
jhsu
1
1.4k
Other Decks in Programming
See All in Programming
Gemini CLIの"強み"を知る! Gemini CLIとClaude Codeを比較してみた!
kotahisafuru
3
970
新しいモバイルアプリ勉強会(仮)について
uetyo
1
250
プロダクトという一杯を作る - プロダクトチームが味の責任を持つまでの煮込み奮闘記
hiliteeternal
0
450
The State of Fluid (2025)
s2b
0
120
MCPで実現できる、Webサービス利用体験について
syumai
7
2.5k
変化を楽しむエンジニアリング ~ いままでとこれから ~
murajun1978
0
710
Nuances on Kubernetes - RubyConf Taiwan 2025
envek
0
140
Claude Code と OpenAI o3 で メタデータ情報を作る
laket
0
110
バイブコーディング × 設計思考
nogu66
0
110
Flutterと Vibe Coding で個人開発!
hyshu
1
250
React 使いじゃなくても知っておきたい教養としての React
oukayuka
18
5.5k
DataformでPythonする / dataform-de-python
snhryt
0
160
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
56
5.8k
For a Future-Friendly Web
brad_frost
179
9.9k
It's Worth the Effort
3n
185
28k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.4k
Automating Front-end Workflow
addyosmani
1370
200k
What's in a price? How to price your products and services
michaelherold
246
12k
Making the Leap to Tech Lead
cromwellryan
134
9.5k
Facilitating Awesome Meetings
lara
54
6.5k
Optimising Largest Contentful Paint
csswizardry
37
3.4k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
6k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Designing for humans not robots
tammielis
253
25k
Transcript
by Joseph Hsu GIT HOOKS HOW TO MAKE FRIENDS
GIT HOOKS by Joseph Hsu HOW TO MAKE FRIENDS
@JHSU Joe Hsu
We all use git (right?)
DVCS - distributed version control system
None
None
None
I wish I could automate...
too lazy to...
Git hooks
Git hooks http://book.git-scm.com/5_git_hooks.html Hooks are little scripts you can place
in $GIT_DIR/ hooks directory to trigger action at certain points.
post-commit no parameters cannot affect the outcome of git-commit
pre-commit run tests, linting
post-receive # <oldrev> <newrev> <refname>
and more...
setup
where? project .git/hooks new repos /usr/share/git-core/templates/hooks/
chmod +x
post-hook What happens after depends on exit status, exit of
non-zero leaves dirty state
pre-commit #!/usr/bin/env bash exit 1
#!/usr/bin/env bash git reset HEAD^ --hard post-commit
Useful examples
cowsay commit-msg * WOOF * * WOOF *
fixing bugs, BRO commit-msg
git commit -m “stuff” commit-msg
None
None
None
AlTeRnAtInG cAsE commit-msg
https://github.com/jhsu/githooks
Thanks.