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
明日から始めるリファクタリング
ryounasso
0
120
Signals & Resource API in Angular: 3 Effective Rules for Your Architecture @BASTA 2025 in Mainz
manfredsteyer
PRO
0
110
株式会社 Sun terras カンパニーデック
sunterras
0
250
CSC305 Lecture 05
javiergs
PRO
0
210
止められない医療アプリ、そっと Swift 6 へ
medley
1
130
CSC305 Lecture 06
javiergs
PRO
0
210
Go言語の特性を活かした公式MCP SDKの設計
hond0413
1
200
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
190
CSC305 Lecture 01
javiergs
PRO
1
400
dynamic!
moro
9
6.9k
詳しくない分野でのVibe Codingで困ったことと学び/vibe-coding-in-unfamiliar-area
shibayu36
3
4.7k
CSC509 Lecture 01
javiergs
PRO
1
440
Featured
See All Featured
Practical Orchestrator
shlominoach
190
11k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
For a Future-Friendly Web
brad_frost
180
9.9k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Music & Morning Musume
bryan
46
6.8k
How GitHub (no longer) Works
holman
315
140k
The Straight Up "How To Draw Better" Workshop
denniskardys
237
140k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
45
2.5k
Building an army of robots
kneath
306
46k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.2k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
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.