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
680
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
2024年のWebフロントエンドのふりかえりと2025年
sakito
1
230
密集、ドキュメントのコロケーション with AWS Lambda
satoshi256kbyte
0
170
社内フレームワークとその依存性解決 / in-house framework and its dependency management
vvakame
1
550
プログラミング言語学習のススメ / why-do-i-learn-programming-language
yashi8484
0
120
『GO』アプリ バックエンドサーバのコスト削減
mot_techtalk
0
130
チームリードになって変わったこと
isaka1022
0
190
Amazon S3 TablesとAmazon S3 Metadataを触ってみた / 20250201-jawsug-tochigi-s3tables-s3metadata
kasacchiful
0
100
バックエンドのためのアプリ内課金入門 (サブスク編)
qnighy
8
1.7k
さいきょうのレイヤードアーキテクチャについて考えてみた
yahiru
3
730
ASP. NET CoreにおけるWebAPIの最新情報
tomokusaba
0
360
負債になりにくいCSSをデザイナとつくるには?
fsubal
9
2.3k
GAEログのコスト削減
mot_techtalk
0
110
Featured
See All Featured
Practical Orchestrator
shlominoach
186
10k
Six Lessons from altMBA
skipperchong
27
3.6k
Producing Creativity
orderedlist
PRO
343
39k
RailsConf 2023
tenderlove
29
1k
A better future with KSS
kneath
238
17k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
175
51k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.1k
Optimizing for Happiness
mojombo
376
70k
The Pragmatic Product Professional
lauravandoore
32
6.4k
How to train your dragon (web standard)
notwaldorf
90
5.8k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
We Have a Design System, Now What?
morganepeng
51
7.4k
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.