{"id":21412851,"url":"https://github.com/hunghg255/git-scm-hooks","last_synced_at":"2025-07-14T02:32:32.767Z","repository":{"id":189994976,"uuid":"680970542","full_name":"hunghg255/git-scm-hooks","owner":"hunghg255","description":"git-scm-hooks","archived":false,"fork":false,"pushed_at":"2024-08-17T07:14:59.000Z","size":222,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T23:01:32.237Z","etag":null,"topics":["git","git-hooks","github-config","npm"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hunghg255.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-21T01:23:03.000Z","updated_at":"2024-10-07T02:24:15.000Z","dependencies_parsed_at":"2024-01-16T08:44:15.868Z","dependency_job_id":"6e58396e-b23b-4c16-b77b-d820610fbe12","html_url":"https://github.com/hunghg255/git-scm-hooks","commit_stats":null,"previous_names":["hunghg255/git-scm-hooks"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hunghg255/git-scm-hooks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunghg255%2Fgit-scm-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunghg255%2Fgit-scm-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunghg255%2Fgit-scm-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunghg255%2Fgit-scm-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hunghg255","download_url":"https://codeload.github.com/hunghg255/git-scm-hooks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunghg255%2Fgit-scm-hooks/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265233753,"owners_count":23731825,"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":["git","git-hooks","github-config","npm"],"created_at":"2024-11-22T18:16:00.591Z","updated_at":"2025-07-14T02:32:31.808Z","avatar_url":"https://github.com/hunghg255.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003ca href=\"https://www.npmjs.com/package/git-scm-hooks\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n\u003cimg src=\"https://api.iconify.design/pajamas:hook.svg?color=%23fd610d\" alt=\"logo\" width='100'/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  A script to verify the commit message format.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/git-scm-hooks\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg src=\"https://badge.fury.io/js/git-scm-hooks.svg\" alt=\"NPM Version\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/git-scm-hooks\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg src=\"https://img.shields.io/npm/dt/git-scm-hooks.svg?logo=npm\" alt=\"NPM Downloads\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://bundlephobia.com/result?p=git-scm-hooks\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg src=\"https://img.shields.io/bundlephobia/minzip/git-scm-hooks\" alt=\"Minizip\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/hunghg255/git-scm-hooks/graphs/contributors\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg src=\"https://img.shields.io/badge/all_contributors-1-orange.svg\" alt=\"Contributors\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/hunghg255/git-scm-hooks/blob/main/LICENSE\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg src=\"https://badgen.net/github/license/hunghg255/git-scm-hooks\" alt=\"License\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n### What is a git hook?\n\nA git hook is a command or script that is going to be run every time you perform a git action, like `git commit` or `git push`.\n\nIf the execution of a git hook fails, then the git action aborts.\n\nFor example, if you want to run `linter` on every commit to ensure code quality in your project, then you can create a `pre-commit` hook that would call `npx lint-staged`.\n\nCheck out [lint-staged](https://github.com/okonet/lint-staged#readme). It works really well with `git-scm-hooks`.\n\nYou can look up about git hooks on the [Pro Git book](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks).\n\n### When to use it\n\n`git-scm-hooks` works well for small-sized projects when you need quickly set up hooks and forget about it.\n\nHowever, this package requires you to manually apply the changes to git hooks. If you update them often, this is probably not the best choice.\n\nAlso, this package allows you to set only one command per git hook.\n\nIf you need multiple verbose commands per git hook, flexible configuration or automatic update of git hooks, please check out the other packages:\n\n- [Lefthook](https://github.com/Arkweid/lefthook)\n- [husky](https://github.com/typicode/husky)\n- [pre-commit](https://github.com/pre-commit/pre-commit)\n\n## Usage\n\n### Add git-scm-hooks to the project\n\n1. Install git-scm-hooks as a dev dependency:\n\n   ```sh\n   npm install git-scm-hooks@latest --save-dev\n   ```\n\n2. Add `git-hooks` to your `package.json`. Fill it with git hooks and the corresponding commands.\n\n   For example:\n\n   ```jsonc\n   {\n      \"script\": {\n        \"prepare\": \"git-scm-hooks\",\n      },\n     \"git-hooks\": {\n       \"pre-commit\": \"npx lint-staged\",\n       \"pre-push\": \"cd ../../ \u0026\u0026 npm run format\",\n\n       // All unused hooks will be removed automatically by default\n       // but you can use the `preserveUnused` option like following to prevent this behavior\n\n       // if you'd prefer preserve all unused hooks\n       \"preserveUnused\": true,\n\n       // if you'd prefer preserve specific unused hooks\n       \"preserveUnused\": [\"commit-msg\"]\n     }\n   }\n   ```\n\n   This configuration is going to run all linters on every `commit` and formatter on `push`.\n\n3. Config from file config\n  - Create `git-hooks.config.{js|ts}` file in the root of your project\n\n    ```js\n    import { defineConfig } from 'git-scm-hooks';\n\n    export default defineConfig({\n      \"pre-commit\": \"npx lint-staged\",\n      \"pre-push\": \"cd ../../ \u0026\u0026 npm run format\"\n    })\n    ```\n\n4. Run the CLI script to update the git hooks with the commands from the config:\n\n   ```sh\n   # [Optional] These 2 steps can be skipped for non-husky users\n   git config core.hooksPath .git/hooks/\n   rm -rf .git/hooks\n\n   # Update ./git/hooks\n   npx git-scm-hooks\n   ```\n\nNow all the git hooks are created.\n\n### Update git hooks command\n\n1. Change the configuration.\n\n2. Run `npx git-scm-hooks` **from the root of your project**.\n\nNote for **yarn2** users: Please run `yarn dlx git-scm-hooks` instead of the command above. More info on [dlx](https://yarnpkg.com/cli/dlx)\n\nNote that you should manually run `npx git-scm-hooks` **every time you change a command**.\n\n\n```json\n{\n  \"pre-commit\": \"npx lint-staged\",\n  \"pre-push\": \"cd ../../ \u0026\u0026 npm run format\"\n}\n```\n\nIf you need to have multiple configuration files or just your-own configuration file, you install hooks manually from it by `npx git-scm-hooks my-config`.\n\n### Uninstall git-scm-hooks\n\n\u003e Uninstallation will remove all the existing git hooks.\n\n```sh\nnpm uninstall git-scm-hooks\n```\n\n## Common issues\n\n### I want to skip git hooks!\n\nYou should use `--no-verify` option\n\nhttps://bobbyhadz.com/blog/git-commit-skip-hooks#skip-git-commit-hooks\n\n### When migrating from `husky` git hooks are not running\n\n**Why is this happening?**\n\nHusky might change the `core.gitHooks` value to `.husky`, this way, git hooks would search `.husky` directory instead of `.git/hooks/`.\n\nRead more on git configuration in [Git book](https://git-scm.com/docs/githooks)\n\nYou can check it by running this command inside of your repo:\n\n`git config core.hooksPath`\n\nIf it outputs `.husky` then this is your case\n\n**How to fix?**\n\nyou need to point `core.gitHooks` value to `your-awesome-project/.git/hooks`. You can use this command:\n\n`git config core.hooksPath .git/hooks/`\n\nvalidate the value is set:\n\n`git config core.hooksPath`\n\nshould output: `.git/hooks/`\n\nThen remove the `.husky` folder that are generated previously by `husky`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhunghg255%2Fgit-scm-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhunghg255%2Fgit-scm-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhunghg255%2Fgit-scm-hooks/lists"}