Last updated: March 2026
Use this page to create, configure, and troubleshoot Git hooks in GitKraken Desktop for commit, push, merge, and rebase workflows. It explains where hooks live, how custom hook paths work, which hook types GitKraken triggers, and how to bypass hooks intentionally when a commit should skip automation.
Requirements and limits
- Scope: Standard Git hook workflows triggered by GitKraken Desktop actions
- Default hook location:
.git/hooks - macOS/Linux requirement: Hook files must be executable or GitKraken Desktop will fail to run them
- Failure behavior: Any non-zero exit code blocks the Git action
- Custom path support: Repository-specific custom hook paths can be configured in Preferences > Git Hooks
- Global hook support: Global hooks can be configured through
core.hooksPathin.gitconfig - Skip behavior: Commits can intentionally bypass hooks from the Commit Panel when needed
Quick Start
- Navigate to your repository’s
.git/hooksdirectory. GitKraken Desktop creates this folder automatically when a repository is initialized. - Create a new file with the hook name (e.g.,
pre-commit). On macOS or Linux, make it executable by runningchmod +x pre-commitin the terminal. - Add your script to the file. Start with
#!/bin/bashand include your validation or automation logic. Any non-zero exit code causes the hook to fail and blocks the Git action. - To set a custom hooks directory for the repository, go to Preferences > Git Hooks and click Browse to select the folder.
- To use global hooks across all repositories, add
hooksPath = /path/to/your/hooksunder[core]in your.gitconfig.
To skip hooks for a specific commit, enable Commit and skip hooks in the Commit Panel. GitKraken Desktop supports pre-commit, commit-msg, post-commit, pre-push, post-merge, post-rewrite, and several other standard hooks.
Where Git hooks are stored
Hooks reside in the hooks subdirectory of the .git folder, created automatically when initializing a repository in GitKraken Desktop. You’ll find it at .git/hooks, typically containing a README.sample file.
Hooks are specific to your local repository and are neither tracked by Git nor copied to new repositories.


If you’re on OSX or Linux, you must set hook files to be executable. GitKraken Desktop will throw an error (e.g., exit code 126) if the file lacks executable permissions.

Any script that returns a non-zero exit code is considered a failure.
How to define a custom hook path
To use a custom Git hook path:
- Go to Preferences Git Hooks.
- Click to set or enter the path.
This setting is defined per repository.

Which hooks GitKraken Desktop supports
GitKraken Desktop supports a wide array of Git hooks. Each hook is triggered by specific actions like commit, merge, or rebase.
Git hooks example
Git hooks automate actions when Git events occur in GitKraken Desktop or the command line. Here’s a basic pre-commit hook example to validate the global Git user email.
Tools needed
- GitKraken Desktop
- Text Editor (e.g., Visual Studio Code)
- Terminal (e.g., GitKraken Terminal)
How to set up a sample hook
1. Navigate to hooks directory
Open Visual Studio Code and go to ~/repo/.git/hooks. Create a new file named pre-commit.

Note 📝 – You may need to make the .git folder visible in VS Code by adjusting files.exclude settings.
2. Make the file executable
Open the GitKraken Terminal and change to the .git/hooks directory. Run:
chmod +x pre-commit

Note 📝 – If your terminal isn’t set up in GitKraken Desktop, refer to the Start Here Tips.
3. Write your bash script
Use a text editor to define your pre-commit script. Start with the correct shebang:
#!/bin/bash
Then add your validation logic using variables like:
globalEmail– value from Git global configworkEmail– required email for commits
The script should compare the current global email with the required email and display an error if they do not match. If the values match, the commit proceeds.
Example:
#!/bin/bash
globalEmail=$(git config --global user.email)
workEmail="[email protected]"
if [ "$globalEmail" != "$workEmail" ]; then
echo "Error: global email does not match required work email ($workEmail)."
exit 1
fi
exit 0
Save the file. Your pre-commit hook is now ready to enforce proper committer email usage before any commit is made.
What a Git hook looks like in action

How environment variables affect Git hooks
On macOS, GUI applications do not inherit shell profile variables. If your Git hooks rely on environment variables set in your shell, use the following command to make them available:
launchctl setenv YOURVAR value
How to bypass Git hooks
To skip Git hooks during a commit, use the Commit and skip hooks option.
Note 📝 – This option disables all hooks triggered by the commit action.

How global Git hooks work
GitKraken Desktop respects global Git hook paths set in your .gitconfig file. These hooks apply to all cloned repositories.
To configure a global path, add the following to your .gitconfig:
[core]
hooksPath = /path/to/your/hooks