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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Joseph Hsu
April 14, 2012
Programming
700
5
Share
Git Hooks: How to Make Friends
Joseph Hsu
April 14, 2012
More Decks by Joseph Hsu
See All by Joseph Hsu
Ruby 2.0
jhsu
3
230
API Versioning
jhsu
1
1.4k
Other Decks in Programming
See All in Programming
実践ハーネスエンジニアリング:ステアリングループを実例から読み解く / Practical Harness Engineering: Understanding Steering Loops Through Real-World Examples
nrslib
5
5.4k
サーバーレスで作る、動画データ管理基盤
oyasumipants
0
130
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
510
PHPでローカル環境用のSSL/TLS証明書を発行することはできるのか? #phpconkagawa
akase244
0
370
いつか誰かが、と思っていた フロントエンド刷新5年間の実践知
kiichisugihara
1
280
ローカルLLMでどこまでコードが書けるか / How much code can be written on a local LLM
kishida
2
360
2026年のソフトウェア開発を考える(2026/05版) / Software Engineering Scrum Fest Niigata 2026 Edition
twada
PRO
23
12k
AIベース静的検査器の偽陽性率を抑える工夫3選
orgachem
PRO
4
460
ソースコード→AST→オペコード、の旅を覗いてみる
o0h
PRO
1
130
AI Agent と正しく分析するための環境作り
yoshyum
2
470
リセットCSSを1行消したらアクセシビリティが向上した話
pvcresin
4
510
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
3k
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1370
200k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
360
The Art of Programming - Codeland 2020
erikaheidi
57
14k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.7k
Darren the Foodie - Storyboard
khoart
PRO
3
3.3k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
170
Designing for Performance
lara
611
70k
Navigating Weather and Climate Data
rabernat
0
190
Information Architects: The Missing Link in Design Systems
soysaucechin
0
920
YesSQL, Process and Tooling at Scale
rocio
174
15k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
Ruling the World: When Life Gets Gamed
codingconduct
0
230
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.