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
CSC509 Lecture 03
javiergs
PRO
0
150
データマイグレーションの成功戦略~サービスリニューアルで失敗しないための実践ガイド~
tkzwtks
8
840
Memory API: Patterns, Use Cases, and Performance
josepaumard
2
200
The future of development – Are our jobs getting harder or easier?
hollycummins
1
190
学生の時に開催したPerl入学式をきっかけにエンジニアが組織に馴染むために勉強会を主催や仲間と参加して職能間の境界を越えていく
ohmori_yusuke
2
330
(Deep|Web) Link support with expo-router
mrtry
0
190
ポケモンで考えるコミュニケーション / Communication Lessons from Pokémon
mackey0225
5
220
MLOps in Mercari Group’s Trust and Safety ML Team
cjhj
1
130
Integrating AI in Your Enterprise Java Applications
ivargrimstad
0
800
Re:proS_案内資料
rect
0
150
Going Staff - Keynote edition
pragtob
0
350
Cloud Adoption Framework にみる組織とクラウド導入戦略
tomokusaba
2
680
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
425
64k
The Power of CSS Pseudo Elements
geoffreycrofte
71
5.3k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
22k
Faster Mobile Websites
deanohume
304
30k
YesSQL, Process and Tooling at Scale
rocio
167
14k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.6k
Why Our Code Smells
bkeepers
PRO
334
57k
Teambox: Starting and Learning
jrom
132
8.7k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
46
2.1k
Build The Right Thing And Hit Your Dates
maggiecrowley
32
2.3k
Building Applications with DynamoDB
mza
90
6k
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.