Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
350
TypeScript 5.9 で使えるようになった import defer でパフォーマンス最適化を実現する
bicstone
1
570
jakarta-security-jjug-ccc-2025-fall
tnagao7
0
100
なあ兄弟、 余白の意味を考えてから UI実装してくれ!
ktcryomm
10
10k
ソフトウェア設計の課題・原則・実践技法
masuda220
PRO
24
20k
ローターアクトEクラブ アメリカンナイト:川端 柚菜 氏(Japan O.K. ローターアクトEクラブ 会長):2720 Japan O.K. ロータリーEクラブ2025年12月1日卓話
2720japanoke
0
200
レイトレZ世代に捧ぐ、今からレイトレを始めるための小径
ichi_raven
0
480
CSC305 Lecture 15
javiergs
PRO
0
220
データファイルをAWSのDWHサービスに格納する / 20251115jawsug-tochigi
kasacchiful
2
100
手軽に積ん読を増やすには?/読みたい本と付き合うには?
o0h
PRO
1
130
Building AI with AI
inesmontani
PRO
1
450
Reactive Thinking with Signals and the new Resource API
manfredsteyer
PRO
0
140
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Code Reviewing Like a Champion
maltzj
527
40k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8k
Optimizing for Happiness
mojombo
379
70k
Docker and Python
trallard
46
3.7k
Testing 201, or: Great Expectations
jmmastey
46
7.8k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.7k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
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.