Git hooks automate processes in your workflow, enhancing code quality and consistency. Common use cases include:
- Commit Message Validation
- Environment Configuration
- Formatting
- Linting
- Testing
Despite their benefits, many developers avoid Git hooks due to a lack of awareness and perceived setup complexity.
HkUp simplifies Git hook management, allowing you to focus on the logic and functionality of your hooks. Plus, with HkUp, your hooks are version-controlled.
git
curl
grep
Note
Windows users need to install Cygwin and add External Dependencies via the Cygwin setup program.
Run the script below:
curl -sSL https://raw.githubusercontent.com/iton0/hkup-cli/main/scripts/install | sh
Tip
To update HkUp, simply rerun the script above. It will automatically replace your current version with the latest release.
# Locates and deletes the HkUp binary
sh -c 'rm "$(command -v 'hkup')"'
This section provides basic information about core usage. For detailed usage information run hkup --help
.
HkUp provides two ways of initializing:
After you create a Git repository, run the following command in your Git repository to initialize HkUp:
hkup init
This creates a .hkup directory and sets the local core.hooksPath variable. If the directory already exists, it will simply update the path variable. The path is relative, ensuring that moving your repository won’t affect hook sourcing.
The above command also works after cloning a repository but HkUp also provides means to wrap Git-related cloning commands for an easier process. By prepending your Git cloning command with hkup --
you can clone your repository and initialize/reinitialize HkUp in a single command.
# Cloning the HkUp Github repository
# and initializing the .hkup folder
hkup -- git clone [email protected]:iton0/hkup-cli.git
Note
This works even for bare Git repositories!
Add or remove hooks easily with:
hkup add <hook-name>
hkup remove <hook-name>
A template is a pre-configured, reusable Git hook that simplifies and automates the process of setting up hooks in a Git repository. With HkUp, you can create, copy, edit, or remove templates, allowing for consistent and easy application of hooks without needing to rewrite scripts each time.
The templates are stored in the HkUp config templates directory that can either be found at $XDG_CONFIG_HOME/hkup/templates or $HOME/.config/hkup/templates depending on your system.
Template files follow the naming convention <template-name>#<hook-name>
where:
<template-name>
is the name of the template.#
is the separator between template and hook name.<hook-name>
is the specific Git hook (e.g., pre-commit, post-merge).
Create a template:
hkup template create
# OR
hkup template create <hook-name>
Copy a template into current working directory:
hkup template copy <template-name>
Edit a template:
hkup template edit <template-name>
Caution
Editing a template will not update its copies.
Remove a template:
hkup template remove <template-name>
windows supportwrapper for git & gh clone- HkUp logo (Expected by end of January)
- Finalize HkUp configuration settings and make config subcommand visible