Skip to content

Instantly share code, notes, and snippets.

@stefansundin
stefansundin / install-pre-commit.sh
Last active Sep 19, 2021
Git pre-commit check to stop accidental commits to master/main/develop branches.
View install-pre-commit.sh
#!/bin/bash
# This gist contains pre-commit hooks to prevent you from commiting bad code or to the wrong branch.
# There are six variants that I have built:
# - pre-commit: stops commits to master/main/develop branches.
# - pre-commit-2: also includes a core.whitespace check.
# - pre-commit-3: the core.whitespace check and an EOF-newline-check.
# - pre-commit-4: only the core.whitespace check.
# - pre-commit-5: elixir formatting check.
# - pre-commit-6: prettier formatting check.
# Set the desired version like this before proceeding: