Awesome Git Hooks Overview
:anchor: A curated list of awesome git hooks
🏠 Home · 🔥 Feed · 📮 Subscribe · ❤️ Sponsor · 😺 CompSciLauren/awesome-git-hooks · ⭐ 919 · 🏷️ Development Environment
Awesome Git Hooks
Awesome Git Hooks
⚓ Easy-to-use git hooks for automating tasks during git workflows.
Git hooks are custom scripts you can use to automate tasks which are triggered before or after a git command is executed. There are two groups of these hooks: client-side and server-side. Client-side hooks are triggered by operations such as committing and merging, while server-side hooks run on network operations such as receiving pushed commits. This repo contains helpful resources as well as a variety of git hook scripts that can be easily customized to serve different purposes.
:heavy_check_mark: Nothing to install/download
:heavy_check_mark: Code is well-documented
:heavy_check_mark: Grab & go! Copy the code you want to use and paste into your .git/hooks folder
Contributions are always welcome! Please see our Contribution Guidelines. Also, if you don't find the script you want below, you can create a new issue (⭐919) to request it.
Contents
Git Hook Scripts
Note: The icon next to each script signifies what language it is written in.
icon | language |
---|---|
bash |
|
python |
|
perl |
commit-msg
- enforce-insert-issue-number (⭐919) - Make sure user did not delete the ISSUE-[#] string that was generated by prepare-commit-msg/insert-issue-number.hook.
post-checkout
- delete-pyc-files (⭐919) - Delete all .pyc files every time a new branch is checked out.
- new-branch-alert (⭐919) - Display a message when a new branch is checked out for the first time.
post-update
- update-server-info (⭐919) - Prepare a packed repository for use over dumb transports (e.g. http).
pre-commit
- dotenvx (⭐919) - Prevent committing your
.env
file(s) to code. - format-code (⭐919) - Run command to format code and re-add any files modified after formatting.
- search-term (⭐919) - Fail commit if a specific term is found in the code.
- spell-check-md-files (⭐919) - Check files with .md extension for spelling errors.
- verify-name-and-email (⭐919) - Fail commit if user.name or user.email is incorrect.
prepare-commit-msg
- include-git-diff-name-status (⭐919) - Include the output of "git diff --name-status -r" into the message, just before the "git status" output.
- insert-issue-number (⭐919) - Insert issue number to beginning of the commit message.
pre-push
- prevent-bad-push (⭐919) - Prevent push of commits where the log message starts with "WIP" (work in progress).
pre-rebase
- prevent-rebase (⭐919) - Prevent topic branches that are already merged to 'next' branch from getting rebased, because allowing it would result in rebasing already published history.
query-watchman
- fsmonitor-watchman (⭐919) - Output to stdout all files that have been modified since a given time.
update
- update (⭐919) - Block unannotated tags from entering.
Quick Start
- Pick a hook, any hook! Try the "verify-name-and-email" one if you're not sure where to start.
- Navigate to your project's hooks folder (.git/hooks).
- You should see a list of files already in there. Create a new file called the exact commit type that you want to use (eg: "commit-msg", "pre-rebase", "pre-commit", etc). Do not give it an extension.
- Open your new file and paste the code from the hook you chose out of this repo (eg: verify-name-and-email.hook (⭐919)).
- Save file. Done! Now the git hook will be triggered automatically.
Tools
Husky (⭐31k) - Manage git hooks with a nice user interface.
Overcommit (⭐3.9k) - A fully configurable and extendable git hook manager.
Git Build Hook Maven Plugin (⭐117) - Install Git hooks and config during a Maven build.
CaptainHook (⭐931) - Git hooks manager for PHP developers.
pre-commit (⭐12k) - A framework for managing and maintaining multi-language pre-commit hooks.
Written Guides
Video Guides
License
This work is licensed under a Creative Commons Attribution 1.0 International License.