Milton Bryant 
DevOpsLead 
for Polished Geek 
Git 
Hooked!
Milton Bryant 
DevOpsLead at Polished Geek 
Working with Joomla since 2010 
Email -Milton@PolishedGeek.com 
Twitter -@Krealic
What hooks are & 
how to use them
Demo #1 
Triggering unit test(s) with pre-commit githook
Changes to Commit 
Commit 
Push 
Repo 
Update 
Local 
Remote 
pre-commit 
prepare-commit-msg 
commit-msg 
post-commit 
pre-receive 
update 
post-receive
Changes to Commit 
Commit 
Push 
Repo 
Update 
Local 
Remote 
pre-commit 
prepare-commit-msg 
commit-msg 
post-commit 
pre-receive 
update 
post-receive 
Checkout 
Rebase 
post-checkout 
pre-rebase 
Merge 
post-merge
Changes to Commit 
Commit 
Push 
Repo 
Update 
Local 
Remote 
pre-commit 
prepare-commit-msg 
commit-msg 
post-commit 
pre-receive 
update 
post-receive 
pre-commit 
code validation 
unit tests 
check for missing files 
If fail, aborts with message and no commit
Alert you to merge conflict code inside of files
Execute Scripts
Changes to Commit 
Commit 
Push 
Repo 
Update 
Local 
Remote 
pre-commit 
prepare-commit-msg 
commit-msg 
post-commit 
pre-receive 
update 
post-receive 
prepare-commit-msg 
edit pre-defined template messages
Changes to Commit 
Commit 
Push 
Repo 
Update 
Local 
Remote 
pre-commit 
prepare-commit-msg 
commit-msg 
post-commit 
pre-receive 
update 
post-receive 
commit-msg 
runs during commit 
use to ensure standards followed 
Example: abort commit if JIRA issue resolution comments missing
Send a pre-defined message or enforce commit signature policy
Changes to Commit 
Commit 
Push 
Repo 
Update 
Local 
Remote 
pre-commit 
prepare-commit-msg 
commit-msg 
post-commit 
pre-receive 
update 
post-receive 
post-commit 
runs only after successful commit 
use for notifications
Notify users when commits or pushes have been made
Changes to Commit 
Commit 
Push 
Repo 
Update 
Local 
Remote 
pre-commit 
prepare-commit-msg 
commit-msg 
post-commit 
pre-receive 
update 
post-receive 
pre-receive 
enforce devpolicies 
can reject entire push
Generate/update ticket or issue under related project
Changes to Commit 
Commit 
Push 
Repo 
Update 
Local 
Remote 
pre-commit 
prepare-commit-msg 
commit-msg 
post-commit 
pre-receive 
update 
post-receive 
update 
executes per branch updated 
Pass/Fail per branch updated 
“mini-pre-receive”
Changes to Commit 
Commit 
Push 
Repo 
Update 
Local 
Remote 
pre-commit 
prepare-commit-msg 
commit-msg 
post-commit 
pre-receive 
update 
post-receive 
post-receive 
team notifications 
continuous integration 
only runs after successful update
Build Log Files
Relocate Files
Demo #2 
Sending a notification to Slack with the post-commit githook
Top 5 Tips
Tip #1 
By default, githooks are not shared to the remote repository.
Tip #2 
You can create a symbolic link from a “hooks” directory
Tip #3 
If responses flicker too fast on the screen, pool them to a file.
Tip #4 
It is possible to bypass hooks by using --no-verify, --no-merge or –no-checkout
Tip #5 
With githooks, you can…
Milton Bryant 
DevOpsLead 
milton@polishedgeek.com 
@Krealic 
PolishedGeek.com @PolishedGeek 
Slides available online 
https://PolishedGeek.com/githooked 
? 
? 
? 
? 
?

"Git Hooked!" Using Git hooks to improve your software development process

  • 1.
    Milton Bryant DevOpsLead for Polished Geek Git Hooked!
  • 2.
    Milton Bryant DevOpsLeadat Polished Geek Working with Joomla since 2010 Email -Milton@PolishedGeek.com Twitter -@Krealic
  • 3.
    What hooks are& how to use them
  • 4.
    Demo #1 Triggeringunit test(s) with pre-commit githook
  • 5.
    Changes to Commit Commit Push Repo Update Local Remote pre-commit prepare-commit-msg commit-msg post-commit pre-receive update post-receive
  • 6.
    Changes to Commit Commit Push Repo Update Local Remote pre-commit prepare-commit-msg commit-msg post-commit pre-receive update post-receive Checkout Rebase post-checkout pre-rebase Merge post-merge
  • 7.
    Changes to Commit Commit Push Repo Update Local Remote pre-commit prepare-commit-msg commit-msg post-commit pre-receive update post-receive pre-commit code validation unit tests check for missing files If fail, aborts with message and no commit
  • 8.
    Alert you tomerge conflict code inside of files
  • 9.
  • 10.
    Changes to Commit Commit Push Repo Update Local Remote pre-commit prepare-commit-msg commit-msg post-commit pre-receive update post-receive prepare-commit-msg edit pre-defined template messages
  • 11.
    Changes to Commit Commit Push Repo Update Local Remote pre-commit prepare-commit-msg commit-msg post-commit pre-receive update post-receive commit-msg runs during commit use to ensure standards followed Example: abort commit if JIRA issue resolution comments missing
  • 12.
    Send a pre-definedmessage or enforce commit signature policy
  • 13.
    Changes to Commit Commit Push Repo Update Local Remote pre-commit prepare-commit-msg commit-msg post-commit pre-receive update post-receive post-commit runs only after successful commit use for notifications
  • 14.
    Notify users whencommits or pushes have been made
  • 15.
    Changes to Commit Commit Push Repo Update Local Remote pre-commit prepare-commit-msg commit-msg post-commit pre-receive update post-receive pre-receive enforce devpolicies can reject entire push
  • 16.
    Generate/update ticket orissue under related project
  • 17.
    Changes to Commit Commit Push Repo Update Local Remote pre-commit prepare-commit-msg commit-msg post-commit pre-receive update post-receive update executes per branch updated Pass/Fail per branch updated “mini-pre-receive”
  • 18.
    Changes to Commit Commit Push Repo Update Local Remote pre-commit prepare-commit-msg commit-msg post-commit pre-receive update post-receive post-receive team notifications continuous integration only runs after successful update
  • 19.
  • 20.
  • 21.
    Demo #2 Sendinga notification to Slack with the post-commit githook
  • 22.
  • 23.
    Tip #1 Bydefault, githooks are not shared to the remote repository.
  • 24.
    Tip #2 Youcan create a symbolic link from a “hooks” directory
  • 25.
    Tip #3 Ifresponses flicker too fast on the screen, pool them to a file.
  • 26.
    Tip #4 Itis possible to bypass hooks by using --no-verify, --no-merge or –no-checkout
  • 27.
    Tip #5 Withgithooks, you can…
  • 28.
    Milton Bryant DevOpsLead milton@polishedgeek.com @Krealic PolishedGeek.com @PolishedGeek Slides available online https://PolishedGeek.com/githooked ? ? ? ? ?