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
200
API Versioning
jhsu
1
1.4k
Other Decks in Programming
See All in Programming
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
0
130
Amazon BedrockでサーバレスなAIお料理ボットを作成する!!
tosuri13
0
230
開発を加速する共有Swift Package実践
elmetal
PRO
0
420
サーバーレスで負荷試験!Step Functions + Lambdaを使ったk6の分散実行
shuntakahashi
6
1.6k
unique パッケージから学ぶ interning と weak reference @ Asakusa.go#3
karamaru
2
820
Securify_エンジニア採用資料
3shake
0
110
僕が思い描くTypeScriptの未来を勝手に先取りする
yukukotani
9
2.4k
【TID2024】模擬講義:プログラマと一緒にゲームをデザインしてみよう!
akatsukigames_tech
0
680
XStateでReactに秩序を与えたい
gizm000
0
740
Kotlin 2.0が与えるAndroid開発の進化
masayukisuda
1
420
いまから追い上げる、Jetpack Compose トレーニング
nyafunta9858
0
620
マルチモジュールにおけるテスト最適化
fxwx23
0
210
Featured
See All Featured
Code Review Best Practice
trishagee
62
16k
How STYLIGHT went responsive
nonsquared
93
5.1k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
248
20k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
36
1.7k
How to name files
jennybc
75
98k
Making the Leap to Tech Lead
cromwellryan
128
8.8k
Why Our Code Smells
bkeepers
PRO
334
56k
Happy Clients
brianwarren
96
6.6k
Optimizing for Happiness
mojombo
375
69k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Typedesign – Prime Four
hannesfritz
39
2.3k
Design by the Numbers
sachag
277
19k
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.