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
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
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
440
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
1.5k
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
1
610
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
170
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
13
3.4k
3Dシーンの圧縮
fadis
1
590
Old Dog, New Tricks: The Java 25 Reinvention - JNation
bazlur_rahman
0
140
CSC307 Lecture 17
javiergs
PRO
0
310
Why Laravel apps break—Mastering the fundamentals to keep them maintainable
kentaroutakeda
1
340
ReactとSvelteのその先、Ripple-TS / Beyond React and Svelte: Ripple-TS
ssssota
3
2k
New "Type" system on PicoRuby
pocke
1
440
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
540
Featured
See All Featured
Statistics for Hackers
jakevdp
799
230k
WENDY [Excerpt]
tessaabrams
11
38k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
Six Lessons from altMBA
skipperchong
29
4.3k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
190
Writing Fast Ruby
sferik
630
63k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
320
The Invisible Side of Design
smashingmag
302
52k
Tell your own story through comics
letsgokoyo
1
940
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
200
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Embracing the Ebb and Flow
colly
88
5.1k
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.