Essential Git for Scientists
  • Introduction
  • Basic Concepts
    • Version Control
    • Git
    • Repo
    • Commits
    • Branches
    • Remotes
    • GitHub
    • De-centralisation
    • Summary
  • Basic Operations
    • Install Git
    • Create a Repo
    • Make a Commit
    • Inspect a Previous Commit
    • Revert a Change
    • Make a Branch
    • Extend a Branch
    • Fast-forward merge
    • Resolve conflicts
  • Intermediate Concepts
    • Commits
    • Three Trees
    • Rebase
    • Fetch
    • Pull
    • Push
  • Advanced Concepts
    • Reset
    • Interactive rebase
    • Formatted patches
    • Blame
    • Stash
    • Log filter
  • Cookbook
    • Undo
    • Branches
    • Diff
    • Stash
    • Merge
    • Hooks
    • Squashing
    • Rebase
    • Interactive Rebase
    • LFS
    • Submodules
    • Remote
    • Force push
    • Identify merged branches
    • Formated patches
    • Apply patches
    • Interactive rebase
    • Squash commits
    • Pull rebase
    • Log
    • Blame
    • Biset
    • Reset
  • Exercise
    • Exercise 1
    • Exercise 2
Powered by GitBook
On this page
  • Rationale
  • How to run
  • More information
  1. Cookbook

Hooks

PreviousMergeNextSquashing

Last updated 1 year ago

Rationale

  • Shell scripts to be triggered when certain actions are performed (e.g. commit).

  • Can be used to automate checks and routine jobs.

  • Hooks are local. They won't be copied using git clone.

How to run

  • The hooks are stored in .git/hooks.

  • By default, they are deactivated by the extension .sample.

  • To use them, remove the .sample extension, e.g. pre-commit.sample -> pre-commit.

  • The hooks are not limited to Bash, you can use Python or Perl, as long as it can be run from the terminal.

More information

Git Hooks (Atlassian)