{"id":13358873,"url":"https://github.com/CompSciLauren/awesome-git-hooks","last_synced_at":"2025-03-12T11:31:02.616Z","repository":{"id":35424758,"uuid":"190923693","full_name":"CompSciLauren/awesome-git-hooks","owner":"CompSciLauren","description":":anchor: A curated list of awesome git hooks","archived":false,"fork":false,"pushed_at":"2024-01-27T03:02:43.000Z","size":868,"stargazers_count":944,"open_issues_count":19,"forks_count":48,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-05-21T13:16:12.147Z","etag":null,"topics":["automation","awesome","awesome-list","bash","git","hooks","script"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CompSciLauren.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-06-08T18:49:38.000Z","updated_at":"2024-05-21T07:55:59.000Z","dependencies_parsed_at":"2024-01-27T04:19:56.482Z","dependency_job_id":"e1ebaa20-14c5-4a80-8d22-b9d6bf929f15","html_url":"https://github.com/CompSciLauren/awesome-git-hooks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CompSciLauren%2Fawesome-git-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CompSciLauren%2Fawesome-git-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CompSciLauren%2Fawesome-git-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CompSciLauren%2Fawesome-git-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CompSciLauren","download_url":"https://codeload.github.com/CompSciLauren/awesome-git-hooks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243208840,"owners_count":20254121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","awesome","awesome-list","bash","git","hooks","script"],"created_at":"2024-07-29T21:03:48.265Z","updated_at":"2025-03-12T11:31:02.167Z","avatar_url":"https://github.com/CompSciLauren.png","language":"Shell","funding_links":[],"categories":["Shell","Technical","Guides","DevOps","bash"],"sub_categories":["awesome-*","Other"],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003ca href=\"https://git-scm.com/\"\u003e\n  \u003cimg width=\"455\" src=\"https://github.com/compscilauren/awesome-git-hooks/blob/master/git-logo.png\" alt=\"Awesome Git Hooks\"\u003e\u003c/a\u003e\u003cbr\u003eAwesome Git Hooks\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://awesome.re\"\u003e\u003cimg src=\"https://awesome.re/badge-flat2.svg\" alt=\"Awesome Lists\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/CompSciLauren/awesome-git-hooks/blob/master/CONTRIBUTING.md\"\u003e\u003cimg src=\"https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square\" alt=\"PRs welcome\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Awesome Git Hooks\n\n\u003e :anchor: Easy-to-use git hooks for automating tasks during git workflows.\n\nGit 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.\n\n:heavy_check_mark: Nothing to install/download\n\n:heavy_check_mark: Code is well-documented\n\n:heavy_check_mark: Grab \u0026 go! Copy the code you want to use and paste into your .git/hooks folder\n\nContributions are _always_ welcome! Please see our [Contribution Guidelines](CONTRIBUTING.md). Also, if you don't find the script you want below, you can [create a new issue](https://github.com/CompSciLauren/awesome-git-hooks/issues/new?assignees=\u0026labels=enhancement\u0026template=new-git-hook-script-request.md\u0026title=) to request it.\n\n## Contents\n\n- [Git Hook Scripts](#git-hook-scripts)\n  - [commit-msg](#commit-msg)\n  - [post-checkout](#post-checkout)\n  - [post-update](#post-update)\n  - [pre-commit](#pre-commit)\n  - [prepare-commit-msg](#prepare-commit-msg)\n  - [pre-push](#pre-push)\n  - [pre-rebase](#pre-rebase)\n  - [query-watchman](#query-watchman)\n  - [update](#update)\n- [Quick Start](#quick-start)\n- [Tools](#tools)\n- [Written Guides](#written-guides)\n- [Video Guides](#video-guides)\n\n## Git Hook Scripts\n\nNote: The icon next to each script signifies what language it is written in.\n\n| icon                                                     | language |\n| -------------------------------------------------------- | -------- |\n| \u003cimg width=\"14\" src=\"bash-icon.png\" alt=\"Bash Icon\"\u003e     | `bash`   |\n| \u003cimg width=\"14\" src=\"python-icon.png\" alt=\"Python Icon\"\u003e | `python` |\n| \u003cimg width=\"14\" src=\"perl-icon.png\" alt=\"Perl Icon\"\u003e     | `perl`   |\n\n### commit-msg\n\n- [enforce-insert-issue-number](https://github.com/CompSciLauren/awesome-git-hooks/blob/master/commit-msg-hooks/enforce-insert-issue-number.hook) - Make sure user did not delete the ISSUE-\\[#] string that was generated by prepare-commit-msg/insert-issue-number.hook. \u003cimg width=\"14\" src=\"python-icon.png\" alt=\"Python Icon\"\u003e\n\n### post-checkout\n\n- [delete-pyc-files](https://github.com/CompSciLauren/awesome-git-hooks/blob/master/post-checkout-hooks/delete-pyc-files.hook) - Delete all .pyc files every time a new branch is checked out. \u003cimg width=\"14\" src=\"python-icon.png\" alt=\"Python Icon\"\u003e\n- [new-branch-alert](https://github.com/CompSciLauren/awesome-git-hooks/blob/master/post-checkout-hooks/new-branch-alert.hook) - Display a message when a new branch is checked out for the first time. \u003cimg width=\"14\" src=\"bash-icon.png\" alt=\"Bash Icon\"\u003e\n\n### post-update\n\n- [update-server-info](https://github.com/CompSciLauren/awesome-git-hooks/blob/master/post-update-hooks/update-server-info.hook) - Prepare a packed repository for use over dumb transports (e.g. http). \u003cimg width=\"14\" src=\"bash-icon.png\" alt=\"Bash Icon\"\u003e\n\n### pre-commit\n\n- [dotenvx](https://github.com/CompSciLauren/awesome-git-hooks/blob/master/pre-commit-hooks/dotenvx.hook) - Prevent committing your `.env` file(s) to code. \u003cimg width=\"14\" src=\"bash-icon.png\" alt=\"Bash Icon\"\u003e\n- [format-code](https://github.com/CompSciLauren/awesome-git-hooks/blob/master/pre-commit-hooks/format-code.hook) - Run command to format code and re-add any files modified after formatting. \u003cimg width=\"14\" src=\"bash-icon.png\" alt=\"Bash Icon\"\u003e\n- [search-term](https://github.com/CompSciLauren/awesome-git-hooks/blob/master/pre-commit-hooks/search-term.hook) - Fail commit if a specific term is found in the code. \u003cimg width=\"14\" src=\"bash-icon.png\" alt=\"Bash Icon\"\u003e\n- [spell-check-md-files](https://github.com/CompSciLauren/awesome-git-hooks/blob/master/pre-commit-hooks/spell-check-md-files.hook) - Check files with .md extension for spelling errors. \u003cimg width=\"14\" src=\"bash-icon.png\" alt=\"Bash Icon\"\u003e\n- [verify-name-and-email](https://github.com/CompSciLauren/awesome-git-hooks/blob/master/pre-commit-hooks/verify-name-and-email.hook) - Fail commit if user.name or user.email is incorrect. \u003cimg width=\"14\" src=\"bash-icon.png\" alt=\"Bash Icon\"\u003e\n\n### prepare-commit-msg\n\n- [include-git-diff-name-status](https://github.com/CompSciLauren/awesome-git-hooks/blob/master/prepare-commit-msg-hooks/include-git-diff-name-status.hook) - Include the output of \"git diff --name-status -r\" into the message, just before the \"git status\" output. \u003cimg width=\"14\" src=\"bash-icon.png\" alt=\"Bash Icon\"\u003e\n- [insert-issue-number](https://github.com/CompSciLauren/awesome-git-hooks/blob/master/prepare-commit-msg-hooks/insert-issue-number.hook) - Insert issue number to beginning of the commit message. \u003cimg width=\"14\" src=\"python-icon.png\" alt=\"Python Icon\"\u003e\n\n### pre-push\n\n- [prevent-bad-push](https://github.com/CompSciLauren/awesome-git-hooks/blob/master/pre-push-hooks/prevent-bad-push.hook) - Prevent push of commits where the log message starts with \"WIP\" (work in progress). \u003cimg width=\"14\" src=\"bash-icon.png\" alt=\"Bash Icon\"\u003e\n\n### pre-rebase\n\n- [prevent-rebase](https://github.com/CompSciLauren/awesome-git-hooks/blob/master/pre-rebase-hooks/prevent-rebase.hook) - Prevent topic branches that are already merged to 'next' branch from getting rebased, because allowing it would result in rebasing already published history. \u003cimg width=\"14\" src=\"bash-icon.png\" alt=\"Bash Icon\"\u003e\n\n### query-watchman\n\n- [fsmonitor-watchman](https://github.com/CompSciLauren/awesome-git-hooks/blob/master/query-watchman-hooks/fsmonitor-watchman.hook) - Output to stdout all files that have been modified since a given time. \u003cimg width=\"14\" src=\"perl-icon.png\" alt=\"Perl Icon\"\u003e\n\n### update\n\n- [update](https://github.com/CompSciLauren/awesome-git-hooks/blob/master/update-hooks/prevent-unannotated-tags.hook) - Block unannotated tags from entering. \u003cimg width=\"14\" src=\"bash-icon.png\" alt=\"Bash Icon\"\u003e\n\n## Quick Start\n\n1. Pick a hook, any hook! Try the \"verify-name-and-email\" one if you're not sure where to start.\n2. Navigate to your project's hooks folder (.git/hooks).\n3. 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.\n\n![create new file](create-new-file.gif)\n\n4. Open your new file and paste the code from the hook you chose out of this repo (eg: [verify-name-and-email.hook](https://github.com/CompSciLauren/git-hooks/blob/master/pre-commit-hooks/verify-name-and-email.hook)).\n5. Save file. Done! Now the git hook will be triggered automatically.\n\n## Tools\n\n- [Husky](https://github.com/typicode/husky) - Manage git hooks with a nice user interface.\n\n- [Overcommit](https://github.com/sds/overcommit) - A fully configurable and extendable git hook manager.\n\n- [Git Build Hook Maven Plugin](https://github.com/rudikershaw/git-build-hook) - Install Git hooks and config during a Maven build.\n\n- [CaptainHook](https://github.com/CaptainHookPhp/captainhook) - Git hooks manager for PHP developers.\n\n- [pre-commit](https://github.com/pre-commit/pre-commit) - A framework for managing and maintaining multi-language pre-commit hooks.\n\n## Written Guides\n\n- [Git hooks documentation at git-scm.com](https://git-scm.com/docs/githooks)\n\n- [Git Pro book by Scott Chacon and Ben Straub](https://git-scm.com/book/en/v2)\n\n- [An Introduction to Git Hooks](https://www.sitepoint.com/introduction-git-hooks/)\n\n- [Atlassian Tutorial on Git Hooks](https://www.atlassian.com/ru/git/tutorials/git-hooks)\n\n- [Easy git hooks with husky](https://www.vojtechruzicka.com/githooks-husky/)\n\n- [Git Hooked](https://www.javascriptjanuary.com/blog/git-hooked 'Git Hooked')\n\n- [How To Use Git Hooks To Automate Development and Deployment Tasks](https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks)\n\n- [Automate Your Workflow with Git Hooks](https://hackernoon.com/automate-your-workflow-with-git-hooks-fef5d9b2a58c)\n\n- [Using JavaScript in Your Git Hooks](https://medium.com/@Sergeon/using-javascript-in-your-git-hooks-f0ce09477334 'Using JavaScript in Your Git Hooks')\n\n- [An In-Depth Look at Git Hooks](https://dzone.com/articles/an-in-depth-look-at-git-hooks)\n\n- [Git hooks and practical uses. Yes, even on Windows.](https://www.tygertec.com/git-hooks-practical-uses-windows/)\n\n- [Automatically Manage Git Hooks with Direnv](https://knpw.rs/blog/direnv-git-hooks)\n\n## Video Guides\n\n- [Git Hooks Part 1 - Getting Started](https://www.youtube.com/watch?v=aB3eq52sZSU)\n\n- [Git hooks and practical uses. Yes, even on Windows.](http://www.youtube.com/watch?feature=player_embedded\u0026v=fMYv6-SZsSo\u0026t=140s)\n\n## License\n\n[![CC0](http://mirrors.creativecommons.org/presskit/buttons/88x31/svg/cc-zero.svg)](https://creativecommons.org/publicdomain/zero/1.0/)\u003cbr /\u003eThis work is licensed under a \u003ca rel=\"license\" href=\"http://creativecommons.org/licenses/by/1.0/\"\u003eCreative Commons Attribution 1.0 International License\u003c/a\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCompSciLauren%2Fawesome-git-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCompSciLauren%2Fawesome-git-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCompSciLauren%2Fawesome-git-hooks/lists"}