Git Hooks — The Missing Tutorial
Using Git Hooks is just like having automated robots who do whatever you want, when a command is run in Git.
Now, since you should be running Git anyway (unless you are running some other version control software) so it is like you’ve got slaves working for you for free! How great is that!
Difficulty: Beginner | Easy | Normal | Challenging
- The tutorial is designed for the Mac, and refers to commands using Mac OS
- Be able to use VIM to make changes to a file (Guide HERE)
- Have some familiarity with Git (Common commands are HERE)
- Have a reason to automate something along with your Git commands (although some suggestions are listed below)
Git: Git is a distributed version-control system for tracking changes in source code during software development
Git Hooks: Programs you can use to tigger actions at points in Git’s execution
Script: A program which is carried out by another program
Vim: This is a contraction of Vi and IMproved. That is, it is a clone (with additions) of the vi text editor for Unix. In other words, it is a command-line interface for creating and manipulating files
The uses of Git Hooks
Git Hooks allow you to run scripts as commands are run using
Git from the command line.
There are loads of opportunities to use this, and get automation working for you.
Here are some ideas:
Enforce preconditions for merging
Make all programmers working on a repository complete their TODOs before committing. No putting off work until tomorrow!