# git演示 **Repository Path**: ccubee/git-demo ## Basic Information - **Project Name**: git演示 - **Description**: git 演示 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-02-01 - **Last Updated**: 2025-11-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # git演示 ## 使用步骤 > 1. 复制 `package.json` `.versionrc` `.commitlintrc.json(可选)` `.gitignore (忽略node文件夹)` > 2. 复制下图 文件 ![img.png](img.png) ### 添加 `package.json` ```json { "name": "your-spring-boot-app", 项目名 "version": "1.0.0", 版本 "scripts": { "release": "standard-version", "release:minor": "standard-version --release-as minor", "release:major": "standard-version --release-as major", "release:patch": "standard-version --release-as patch", "changelog": "standard-version --dry-run" }, "devDependencies": { "standard-version": "^9.5.0" } } ``` ## 具体步骤 ### 安装node 依赖 ```sql npm init -y npm install --save-dev standard-version ``` ### 添加版本控制 配置 `.versionrc ` ```json { "header": "# 🚀 Spring Boot 项目变更日志\n\n> 自动化生成的版本发布记录\n\n## 版本规范\n- **主版本号**:不兼容的 API 修改\n- **次版本号**:向下兼容的功能性新增 \n- **修订号**:向下兼容的问题修正\n\n", "types": [ { "type": "feat", "section": " 🌟 新功能", "hidden": false }, { "type": "fix", "section": " 🐞 Bug 修复", "hidden": false }, { "type": "docs", "section": " 📖 文档更新", "hidden": false }, { "type": "style", "section": " 💅 代码样式", "hidden": false }, { "type": "refactor", "section": " 🔄 代码重构", "hidden": false }, { "type": "perf", "section": " ⚡ 性能优化", "hidden": false }, { "type": "test", "section": " 🧪 测试相关", "hidden": false }, { "type": "build", "section": " 🛠 构建工具", "hidden": false }, { "type": "ci", "section": " 🔧 CI 配置", "hidden": false }, { "type": "chore", "section": " 📋 杂项任务", "hidden": false }, { "type": "revert", "section": " ↩️ 回滚操作", "hidden": false } ], "skip": { "tag": true }, "packageFiles": [ { "filename": "package.json", "type": "json" } ], "bumpFiles": [ { "filename": "package.json", "type": "json" } ], "compareUrlFormat": "https://github.com/your-username/your-repo/compare/{{previousTag}}...{{currentTag}}", "commitUrlFormat": "https://github.com/your-username/your-repo/commit/{{hash}}", "issueUrlFormat": "https://github.com/your-username/your-repo/issues/{{id}}", "userUrlFormat": "https://github.com/{{user}}", "releaseCommitMessageFormat": "chore(release): {{currentTag}}" } ``` > 说明 ```sql 1. feat: 新功能(feature) 当提交引入了新的功能时使用。 这会使得版本号中的次版本号(minor)增加。 2. fix: 修复bug 当提交修复了一个bug时使用。 这会使得版本号中的修订号(patch)增加。 3. docs: 文档更新 仅当修改了文档,比如README、API文档等时使用。 4. style: 代码风格调整 修改代码风格,例如空格、格式化、缺少分号等,不改变代码逻辑。 refactor: 代码重构 既不是修复bug也不是添加新功能的代码更改,即重构代码。 5. test: 测试相关 添加或修改测试用例,但不包括生产代码的更改。 6. chore: 构建过程或辅助工具的变动 例如更改构建脚本、依赖管理、工具配置等,不修改源文件或测试。 7. revert: 回滚先前的提交 当撤销一个先前的提交时使用。 此外,还有一些其他常见的类型,但不在上述列表中,例如: 8. perf: 性能优化 9. ci: 持续集成相关的更改 10. build: 构建系统或外部依赖的更改(例如npm、webpack等) ``` ## Git 提交规范配置(可选) `.commitlintrc.json` ```json { "extends": ["@commitlint/config-conventional"], "rules": { "type-enum": [ 2, "always", ["feat", "fix", "docs", "style", "refactor", "test", "chore", "revert"] ] } } ``` ### 安装 commitlint ```sql npm install --save-dev @commitlint/config-conventional @commitlint/cli ``` ### 修改pom文件 ```xml src/main/resources **/* . package.json CHANGELOG.md ${project.build.outputDirectory} ``` ## 指令 查询标签 ```git git ls-remote --tags origin # 1. 首先进行 dry-run 测试 npx standard-version --dry-run ```