원클릭으로
git-branch-bump-pom-version
在创建分支前,先读取并展示 pom.xml 当前版本号,让用户输入分支版本号;自动更新 main 分支 pom 版本并按版本创建分支。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
在创建分支前,先读取并展示 pom.xml 当前版本号,让用户输入分支版本号;自动更新 main 分支 pom 版本并按版本创建分支。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Analyze local code changes, automatically generate meaningful commit messages based on the changes, and push to remote repository (GitHub, GitLab, Gitee, Alibaba Cloud DevOps, etc.). Use when the user wants to commit and push changes with auto-generated commit messages, or needs help writing good commit messages.
Stop Git from tracking a file or directory while keeping it on disk (remove from index only). Use when the user has accidentally committed files/folders (e.g. node_modules, build output) and wants to "unlink" or "disassociate" them from Git, then prevent future commits via .gitignore.
Initialize git in a local project without a repository, connect it to a remote, and generate a proper .gitignore. Use when the user wants to link a local project to a remote git repository, set up git for an existing project, push a local project to GitHub/GitLab, or needs a .gitignore file for their project type.
将 Maven/Spring Boot 构建产物(可执行 JAR、target/lib 依赖目录、可选 JRE)归档到 GitHub Releases。在用户需要发布版本、上传 JAR/lib/JRE 到 GitHub Release 或“归档到 Releases”时使用。
| name | git-branch-bump-pom-version |
| description | 在创建分支前,先读取并展示 pom.xml 当前版本号,让用户输入分支版本号;自动更新 main 分支 pom 版本并按版本创建分支。 |
用于 “打分支前必须先更新 pom.xml 版本号” 的工作流:从 main 分支出发,先输出当前版本号 → 用户输入目标分支版本号 → 修改 pom.xml 版本号 → 创建并切换到以该版本命名的分支。
| 参数 | 说明 | 示例 | 默认值 |
|---|---|---|---|
project_root | 项目根目录绝对路径 | /Users/zhangkai/IdeaProjects/npe_get_jobs | 当前工作目录 |
base_branch | 从哪个分支创建新分支(必须是主分支) | main | main |
branch_version | 目标分支版本号(将写入 pom.xml) | v1.1.0 / v1.1.0-rc1 | 无 |
branch_name | 新分支名(建议含版本) | release/v1.1.0 / feature/v1.1.0-xxx | release/<branch_version> |
base_branch 开始(通常是 main),并且在创建分支之前先更新 pom.xml 的 <version>。pom.xml 顶部:<project>/<version>(例如第 9 行附近)。v 前缀保持一致(如 v1.0.0)。cd <project_root>
git status --porcelain
git branch --show-current
cd <project_root>
git checkout <base_branch>
git pull --rebase
优先使用 Maven 读取(不依赖行号):
cd <project_root>
mvn -q help:evaluate -Dexpression=project.version -DforceStdout
如果 Maven 不可用,再直接查看 pom.xml 顶部 <version>(靠近第 9 行)。
branch_version要求用户输入一个目标版本号,例如:
v1.1.0v1.1.0-rc1校验建议:
pom.xml 版本号(在 main 分支上完成)推荐用 Maven 统一修改(会同时更新 pom.xml):
cd <project_root>
mvn -q versions:set -DnewVersion=<branch_version> -DgenerateBackupPoms=false
然后再次确认版本号:
mvn -q help:evaluate -Dexpression=project.version -DforceStdout
git diff -- pom.xml
默认分支名:release/<branch_version>(可按团队规范调整)。
cd <project_root>
git checkout -b <branch_name>
cd <project_root>
git branch --show-current
mvn -q help:evaluate -Dexpression=project.version -DforceStdout
git status --short
期望结果:
pom.xml 版本号已变为 branch_version| 场景 | 原因 | 处理 |
|---|---|---|
versions:set 不存在 | 缺少 versions-maven-plugin | 直接执行命令通常会自动解析插件;若失败,可在命令中显式指定插件版本或临时改 pom.xml(不推荐) |
git pull --rebase 冲突 | 主分支有更新 | 先解决冲突并确保工作区干净后再继续 |
用户想从 master 分支切 | 仓库主分支叫法不同 | 将 base_branch 设为 master,流程不变 |