{"id":23602814,"url":"https://github.com/lzwme/git-helper","last_synced_at":"2025-11-05T06:30:39.287Z","repository":{"id":64570377,"uuid":"360549332","full_name":"lzwme/git-helper","owner":"lzwme","description":"一个简单的 git commit 等操作的辅助小工具","archived":false,"fork":false,"pushed_at":"2025-01-17T02:22:36.000Z","size":889,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-03T02:34:20.541Z","etag":null,"topics":["commit","git"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/lzwme.png","metadata":{"files":{"readme":"README.MD","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","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":"2021-04-22T14:32:03.000Z","updated_at":"2025-01-17T02:22:38.000Z","dependencies_parsed_at":"2023-02-09T09:00:22.780Z","dependency_job_id":"83e9d715-e167-4d0d-b7d0-80533ed0fcc2","html_url":"https://github.com/lzwme/git-helper","commit_stats":{"total_commits":65,"total_committers":1,"mean_commits":65.0,"dds":0.0,"last_synced_commit":"18d10771c0981d557899f7750c0315e03cb2816c"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzwme%2Fgit-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzwme%2Fgit-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzwme%2Fgit-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzwme%2Fgit-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lzwme","download_url":"https://codeload.github.com/lzwme/git-helper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239331483,"owners_count":19621221,"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":["commit","git"],"created_at":"2024-12-27T12:13:21.328Z","updated_at":"2025-11-05T06:30:39.237Z","avatar_url":"https://github.com/lzwme.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![@lzwme/git-helper](https://nodei.co/npm/@lzwme/git-helper.png)][npm-url]\n\n# @lzwme/git-helper\n\n[![NPM version][npm-badge]][npm-url]\n[![node version][node-badge]][node-url]\n![license](https://img.shields.io/github/license/lzwme/git-helper)\n\n[![build status](https://github.com/lzwme/git-helper/actions/workflows/node-ci.yml/badge.svg)](https://github.com/lzwme/git-helper/actions/workflows/node-ci.yml)\n[![npm download][download-badge]][download-url]\n[![GitHub issues][issues-badge]][issues-url]\n[![GitHub forks][forks-badge]][forks-url]\n[![GitHub stars][stars-badge]][stars-url]\n\n一个基于 `Node.js` 的简单的 `git commit` 等操作的辅助性工具。\n\n在中大型前端项目的开发中，为了编码规范与质量保障，基本都会配置 husky、lint-staged 等 githooks 工具来约束 git 提交的规范性检测，如 commitlint、ESLint、StyleLint、prettier、单元测试等等。\n\n这些约束在保障开发提交规范性的同时，也大大的增加了 `git commit` 的执行时间，随着项目开发周期的增长和复杂度的提升，带来的开发体验也会越来越糟糕。\n\n最常见的 `git commit` 动作一般主要为：\n\n```bash\ngit add *\ngit commit -m \"feat: test\"\ngit pull --rebase\ngit push\n```\n\n那么不如将这个动作写为一个脚本，让它自己飞一会儿。本项目主要就是实现为一个包含这样的功能的小工具。\n\n你也可以结合一些 git 客户端提供的工作流功能一起辅助性配置该流程。\n\n## INSTALL\n\nnpm global install:\n\n```bash\nnpm i -g @lzwme/git-helper\ngh --help\n```\n\nor use `npx`:\n\n```bash\nnpx @lzwme/git-helper -h\n```\n\n![](public/img/githelper-commit-amend.png)\n\n## Useage\n\n```bash\ngithelper --help\ngh commit --help\ngh run --help\n```\n\n**提示：**\n\n`githelper` 有一个短的别名 `gh`，类似的：\n\n- `githelper commit` 命令有短别名 `gh cm`、`gh c`\n- `gh run` 命令有短别名： `gh r`\n\n`gh commit` 示例：\n\n```bash\n# git add \u0026 git commit \u0026 git pull --rebase\ngh c -m \"chore: update deps\"\n\n# git add \u0026 git commit --amend\ngh c -m \"chore: update deps\" --amend\n\n# git add \u0026 git commit \u0026 git pull --rebase \u0026 git push\ngh c -m \"chore: update deps\" -p\n\n# git add \u0026 git commit --no-veify \u0026 git pull --rebase \u0026 git push\ngh c -m \"chore: update deps\" -p -n\n\n# git add \u0026 # git commit --no-veify \u0026 git push\ngh c -m \"chore: update deps\" -p -n -N\n```\n\n`gh run` 示例：\n\n```bash\n# help\ngh r -h\n\n# git update\ngh r -u\n\n# run custom conmand group of abc\ngh r -c abc\n```\n\n## 配置文件\n\n配置文件名称为 `git-helper.config.js`， 默认在当前项目执行目录下，也可以通过命令行参数 `-c` 指定。示例：\n\n```ts\n// git-helper.config.js\n\n/**\n * @type {import('@lzwme/git-helper').IConfig}\n */\n export default {\n  debug: false,\n  baseDir: process.cwd(),\n  commit: {\n    messageReg: /^(fix|feat|pref|test|doc):.+/,\n    push: true,\n    noVerify: false,\n  },\n  run: {\n    cmds: {\n      test: {\n        desc: 'test',\n        list: ['npm run lint', 'npm run test']\n      },\n    },\n  },\n};\n```\n\n配置文件是可以缺省的，命令行参数的优先级比它更高。\n\n### 常见使用方式示例\n\n- `githelper commit` 命令常用方式示例：\n\n```bash\n# 执行 git commit，包括 add、commit、rebase\ngh c -m \"feat: test for lzwme\"\n\n# 执行 git commit，包括 add、commit、rebase、push\ngh c -m \"feat: test for lzwme\" --push\n\n# 执行 git commit，覆盖上一次的提交(若最近一次提交已推送至远端则失败)\ngh c -m \"feat: test for lzwme\" --amend\n\n# 执行 git commit，覆盖上一次的提交，且不修改注释\ngh c --amend\n\n# 执行 git commit，不执行 pull、push\ngh c -m \"feat: test for lzwme\" --no-push --no-pull\n```\n\n## 开发\n\n本地二次开发：\n\n```bash\ngit clone https://github.com/lzwme/git-helper\nyarn install\nnpm link\nyarn dev\n```\n\n或者 fork 本项目进行代码贡献。\n\n**欢迎贡献想法与代码。**\n\n## License\n\n`@lzwme/git-helper` is released under the MIT license.\n\n该插件由[志文工作室](https://lzw.me)开发和维护。\n\n\n[stars-badge]: https://img.shields.io/github/stars/lzwme/git-helper.svg\n[stars-url]: https://github.com/lzwme/git-helper/stargazers\n[forks-badge]: https://img.shields.io/github/forks/lzwme/git-helper.svg\n[forks-url]: https://github.com/lzwme/git-helper/network\n[issues-badge]: https://img.shields.io/github/issues/lzwme/git-helper.svg\n[issues-url]: https://github.com/lzwme/git-helper/issues\n[npm-badge]: https://img.shields.io/npm/v/@lzwme/git-helper.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/@lzwme/git-helper\n[node-badge]: https://img.shields.io/badge/node.js-%3E=_10.0.0-green.svg?style=flat-square\n[node-url]: https://nodejs.org/download/\n[download-badge]: https://img.shields.io/npm/dm/@lzwme/git-helper.svg?style=flat-square\n[download-url]: https://npmjs.org/package/@lzwme/git-helper\n[bundlephobia-url]: https://bundlephobia.com/result?p=@lzwme/git-helper@latest\n[bundlephobia-badge]: https://badgen.net/bundlephobia/minzip/@lzwme/git-helper@latest\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flzwme%2Fgit-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flzwme%2Fgit-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flzwme%2Fgit-helper/lists"}