Search
Close this search box.

Git Blog

Releasing the Power of Git

Learning Git: What are Git Hooks?

Git hooks explained

Git hooks are shell scripts that trigger when you perform a specific action in Git. They are useful tools for automating checks as you move through your general workflow.

You can trigger Git hooks around specific Git actions. For example, you can set up a Git hook that prevents you from committing if the hook script detects a problem.  

Git hooks exist as simple text files in your .git/hooks directory.

If you just initialized a repo, there will be a .git folder in your repo with some of the sample Git hooks under the hooks folder. If you do not see this folder, you will need to first make sure you can see hidden folders on your operating system.

Git hooks tutorial video

Watch this short video to learn more about Git hooks. At the end, we’ll show you how Git hooks work in GitKraken.

Git hooks supported by GitKraken

Beneath each hook is a list of the actions during which GitKraken calls that hook:

  • pre-commit:
    • Commit
    • Amend
    • Merge Resolve
  • prepare-commit-msg:
    • Commit
    • Amend
    • Cherrypick
    • Merge
    • Squash
    • Revert
  • commit-msg:
    • Commit
    • Amend
    • Merge Resolve
  • post-commit:
    • Commit
    • Amend
    • Cherrypick
    • Merge Resolve
    • Revert
  • pre-rebase:
    • Rebase
    • Squash
  • post-checkout:
    • Checkout
    • Discard Changes (selectively)
  • post-merge:
    • Merge (Without Conflicts)
    • Fast-Forward
  • post-rewrite:
    • Amend
    • Squash
    • Rebase
  • pre-push:
    • Push Branch
    • Push Tag
    • Delete Remote Branch
    • Delete Remote Tag

Like this post? Share it!

Read More Articles

Make Git Easier, Safer &
More Powerful

with GitKraken
Visual Studio Code is required to install GitLens.

Don’t have Visual Studio Code? Get it now.

GitKraken Browser Extension

Your bridge between apps
Track PRs   –   View PRs in GitKraken or VS Code  –   Work More Effectively with Repo Providers

GitLens for VS Code

Your IDE, Smarter with Git
30M+ INSTALLS
Bring PRs, WIPs & Issues to the Terminal – Run Multi-Repo Commands Manage Groups of Repos – Suggest Code Revisions

GitKraken CLI

New ultimate CLI for Git Collaboration
Bring PRs, WIPs & Issues to the Terminal – Run Multi-Repo Commands Manage Groups of Repos – Suggest Code Revisions

GitKraken.dev

Your command center in the browser
Track PRs & Issues – Suggest and Share Code Changes – Ramp Up New Devs Faster Bring Your Team Together – Secure and Control Your Data

GitKraken Desktop

Simplify Git for any OS

Visualize Git, Minimize Mistakes   –   Unblock PR & Code Reviews   –   Manage Multiple Repos      Resolve Merge Conflicts with Ease   –   Ramp Up Devs Faster