Better Living Through 

 Git Hooks

What are some things you try to do before you commit or push your code?

git hooks can

run your tests

standardize commit messages

clean up your workflow, you slobs

(No waiting for your build!)

Lint Your Code

and more

pre-commit

automated commit msg

prepare-commit-msg

commit msg made

commit-msg
post-commit

commit lifecycle

pre-commit

Let's write a

hook!

const add2 = number => number + 2;
const add3 = number => number + 3;

module.exports = { add2, add3 };
const addNum = num => {
  const add = number => number + num;

  return add;
}

const add2 = addNum(2);
const add3 = addNum(3);

module.exports = { add2, add3 };

Before

After

(this code doesn't

really matter)

#!/bin/sh

echo "\Running tests:\n"

npm run test

when things are dandy

Let's say I wrote bad code that does not pass my tests:

when things are not dandy

Be a good person.

use git hooks.

thatpersonfromthething.com

Copy of Better Living Through Git Hooks

By letakeane

Copy of Better Living Through Git Hooks

Tired of inconsistent commit messages? Find yourself forgetting to run your test suites before you commit a change? Do you have to push extra commits to remove comments? This talk will show you how to make use of git hooks to automate your git workflow and ensure consistency, clean commits, and your own peace of mind.

  • 1,009