匠人学院 JR Academy
  • Position

    Where am I now, and where should I go?

    How your job is changing, where your experience can take you and what you still need for a target role, worked out from what you have actually done. Free, and the full result needs no sign-up.

    Analyse my career and skills

    Look up a career

    Will AI replace my job?AI impact and transition paths for common careersNew jobs in the AI eraWhat they do, what they need, how to move in

    Focused tools

    AI Engineer interview readiness30 timed questions on what you still need before interviewsCareer personality testDirections that suit how you workReturning to China checkJob prospects in China by school, major and graduation date

    AI coach

    Talk to your AI coachStill unsure after your result? Talk through what is holding you back
  • Core courses

    AI Engineer BootcampEngineering bootcamp from LLM apps to agentsAI Engineer Full-Stack Project Class16 weeks · RAG and full-stack AI projectsVibe Coding Masterclass8 weeks · direct agents to build and ship a productAI Essentials10 hours · use AI for email, reports, data and copyAI Office Automation Course8 weeks · help a whole company adopt AIOne-Person Company (OPC) Bootcamp15 weeks in person · build a one-person company with AIAll courses →

    AI engineering

    Machine Learning & Data Engineering Full-Stack ClassAI Agent & MCP Project BootcampAI Engineer Core TechniquesAI Engineer FoundationsAI Engineer Advanced: RAG to Agents and TuningClaude Code TasterAll AI engineering courses →

    AI at work

    AI Coding for everyoneClaude Code One-Day Masterclass (Non-Technical)Enterprise AI Automation BootcampAI Marketing BootcampAI Risk, Governance and Audit CourseOpenClaw 4-Week Personal AI Assistant BootcampAll AI-at-work courses →

    Career development

    AI Product Manager (BA) Bootcamp + InternshipAustralia IT Interview BootcampAustralia IT Technical Interview BootcampAustralia IT Resume BootcampAustralia Big Tech Job Search BootcampAustralia IT Career Planning BootcampAll career courses →

    Learn free first

    Vibe CodingAI for office workPrompt MasterAI EngineerAI data analysisResource centerInstructorsAll learning paths →
  • Evidence

    What will convince an employer?

    Certifications, projects, team work and competition entries, collected into one portfolio.

    See the portfolio

    Certifications

    Cert Master · all certificationsPrep and mock exams for AWS, Azure, GCP, Claude and moreAWS CLF-C02Entry-level AWS cloud certificationAWS SAA-C03Entry certification for cloud architectsClaude certificationsAnthropic Claude certification seriesAll certifications →

    Projects and team work

    P3 team projectsBuild a project with real teammates in a simulated team workflowP3 project experienceThe parts of a P3 project that go on your resumeDemo DayProject showcaseP3 certificatesProof once a project is completeAll of P3 →

    Competitions and work

    HackathonsBuild something against the clockSubmit your workAdd your project to the showcaseCareerOS portfolioDo tasks in the desktop app; your results become portfolio pieces
    Cert MasterBrowser extension, app and mini programScreenshot a question for analysis and practise anywhereAbout Cert Master
  • Connect

    How do I get myself in front of employers?

    Resume, interviews, referrals and mentors. See how far you are from the target role first, then decide what to fix.

    Start with Jobpin

    Resume and openings

    Graduate careersGraduate preparation across Australia, China, Malaysia, Singapore, the US and UKJobpinAI job search workspace: resume, roles, applicationsAI resumeRewrite your resume against a job descriptionReferralsRoles shared by students and mentorsOpportunitiesInternships, projects and collaborationsOffer boardOffers students have received

    Interviews

    AI Engineer interview guideSeven areas, with worked examplesFDE interview guideFive rounds, from scoping to the customer roundAI mock interviewPractise by text or voice and see the gapsInterview storiesReal interview experiencesSystem Design handbookPrepare for system design interviewsAll interview prep →

    Mentors

    1:1 mentorsBook AI, career and technical mentors by the hourGroup tutoringShare a tutor with a few others and pay less eachCareer coachingResume, interview and direction packages
    Jobpin desktopOne workspace for the whole job searchOrganise real experience and refine resume versions for target roles on macOS or Windows.About Jobpin
BusinessMembershipDownload CareerOS
0
匠人学院 JR Academy

Follow Us

linkedinfacebooktwitterinstagramyoutube

We Accept

/image/layout/pay-paypal.png/image/layout/pay-visa.png/image/layout/pay-master-card.png/image/layout/pay-airwallex.png/image/layout/pay-alipay.png
Airbotix · AI learning & creation for kids Another Life · AI story game
Products46

CareerOS and tools

  • CareerOS
  • Cert Master
  • Jobpin
  • Jobpin web
  • Jobpin report
  • Jobpin desktop download
  • My job search reports
  • Buy report credits
  • Jobpin billing
  • AI Toolbox
  • AI Skill Marketplace

Membership

  • Membership
  • AI membership

Courses

  • Bootcamps
  • Training Camp
  • Kanban learning
  • AI Builder course
  • MCP course
  • NotebookLM workshop
  • Business Analyst course
  • Web Full-Stack Bootcamp
  • DevOps Bootcamp
  • Data Engineering Bootcamp
  • Data Analysis Bootcamp
  • Coding for Beginners
  • Algorithm Bootcamp

Career services

  • Graduate careers
  • Graduate careers in Australia
  • Graduate careers in China
  • Graduate careers in Malaysia
  • Graduate careers in Singapore
  • Graduate careers in the US
  • Graduate careers in the UK
  • 1:1 coaching
  • Career coaching
  • AI Engineer VIP
  • BA & PM Internship
  • Data Science Internship
  • Data Analysis Internship
  • Marketing Internship
  • Resume Review
  • Interview Coaching
  • Job Application Service
  • Job Monitoring
  • LinkedIn Management
  • LinkedIn Networking
Library57

Learning paths

  • All Learning Paths
  • AI Engineer
  • Context Engineering
  • Vibe Coding
  • Prompt Master
  • AI Builder
  • AI Product Manager
  • Python Basics
  • AI Productivity
  • AI Data Analysis
  • AI Finance
  • AI Content Creation
  • AI Image Creation
  • Frontend Development
  • Hermes Agent
  • OpenClaw Local Agent

Interactive labs

  • Prompt Lab
  • Frontend Lab
  • JavaScript Lab
  • Python Lab
  • AWS Lab
  • Azure Lab
  • LLM Lab
  • Git Lab

Reference and guides

  • Resources
  • Wiki
  • Cheat sheets
  • Roadmaps
  • AI roadmaps
  • Videos
  • Ebooks
  • Blog
  • Interview handbook
  • Mock exams
  • Free resources

Cities

  • Sydney
  • Melbourne
  • Brisbane
  • Adelaide
  • Singapore
  • Kuala Lumpur
  • London
  • New York
  • San Francisco
  • Los Angeles
  • Seattle
  • Toronto
  • Vancouver

Immigration

  • Australia Immigration
  • Skilled Visa 189/190/491
  • Employer Sponsored 482/186/494
  • Business Visa 188/888
  • UK Immigration
  • US Immigration
  • Canada Immigration
  • Singapore immigration
  • Malaysia immigration
Business20

For business

  • AI for Business
  • Business portal sign-in
  • Corporate Training
  • Internship Partnership
  • Recruitment Partnership
  • Enterprise (EN)

Metatree AI Lab

  • Metatree AI Lab (Chinese)
  • AI solutions (Chinese)
  • Digital employees (Chinese)
  • Case studies (Chinese)
  • Metatree AI Lab
  • AI services
  • Digital employees
  • Case studies

AI education for kids

  • Airbotix — AI Learning & Creation for Kids
  • AU Family Resource Hub
  • NAPLAN Report Guide
  • My School Data Guide
  • Sydney Private School Fees 2026
  • Kids Coding Programs
About15

Company

  • About Us
  • Our Mentors
  • Become a Mentor
  • Metaverse Classroom
  • JR Careers
  • Another Life — AI Story Game
  • Contact Us

Help and policies

  • FAQs
  • Terms & Conditions
  • Privacy Policy
  • Cancellation & Refund Policy
  • Site map

Friend links

  • CS Browser

Contact

  • hello@jiangren.com.au
  • 0421-672-555

Offices

Level 10b, 144 Edward Street, Brisbane CBD (Headquarter)
Level 2, 171 La Trobe St, Melbourne VIC 3000
45A13, Block B, Oriental Hope Tianxiang Plaza, 500 Tianfu Avenue Middle Section, Wuhou District, Chengdu, Sichuan, China
Business Hub, 155 Waymouth St, Adelaide SA 5000
Disclaimer
footer-disclaimerfooter-disclaimer

JR Academy acknowledges Traditional Owners of Country throughout Australia and recognises the continuing connection to lands, waters and communities. We pay our respect to Aboriginal and Torres Strait Islander cultures; and to Elders past and present. Aboriginal and Torres Strait Islander peoples should be aware that this website may contain images or names of people who have since passed away.

All content on the JR Academy website, including course materials, logos, and information provided, is protected under Australian intellectual property laws. Unauthorized use, sale, distribution, reproduction, or modification is strictly prohibited. Violations may result in legal action. By accessing our website, you agree to respect our intellectual property. JR Academy Pty Ltd reserves all rights, including patents, trademarks, and copyrights. Any infringement will be subject to legal prosecution. View Terms of Service

© 2017-2026 JR Academy Pty Ltd. All rights reserved.

ABN 26621887572

HomeLearnCoursesCerts
  1. Home
  2. Learn
  3. Blog
  4. Claude Code 从入门到实战 — Git 工作流自动化
JR Academy · BlogCareer insights

Claude Code 从入门到实战 — Git 工作流自动化

让 Claude Code 帮你管理分支、提交、PR

Published2026-11-30
Reading time2 min
Author

Contents

  • 自动提交
  • 创建 PR:从命令到上线
  • 基本用法
  • 接 GitHub MCP Server 之后
  • 用模板生成 PR Description
  • PR 创建后的跟踪
  • 分支管理
  • 实战场景:hotfix
  • 解决 Merge Conflict
  • 快速解决
  • 详细工作流
  • 常见陷阱
  • Git Worktree 配合 Claude Code
  • 为什么需要 worktree
  • 基本用法
  • 让 Claude Code 帮你管理 worktree
  • 多 agent 并行任务
  • 代码审查
  • 安全机制

自动提交

改完代码直接说:

> 提交这些修改

Claude Code 会:

  1. git diff 查看所有改动
  2. 分析改动内容,生成语义化的 commit message
  3. 只 stage 相关文件(自动跳过 .env、node_modules 等敏感文件)
  4. 展示 commit 预览,等你确认后执行

Claude Code Git 工作流示意

生成的 commit message 格式规范,比如:

feat: add input validation to user registration form

- Add email format check with regex
- Add password strength requirements  
- Show inline error messages on invalid input

创建 PR:从命令到上线

基本用法

> 创建一个 PR,目标分支 main,描述这次改了什么

Claude Code 会自动生成 PR title 和 description,包括:

  • 改动摘要(从 diff 提炼)
  • 影响范围
  • 测试说明
  • 关联的 issue(如果 commit message 里有 #123 引用)

接 GitHub MCP Server 之后

配置好 GitHub MCP Server(见第 5 章),PR 创建变成真正的一步操作:

> 我这个功能分支做完了,帮我推到 remote,然后对 main 开 PR,
  标题写「feat: 用户个人资料页改版」,reviewer 加上 @alice @bob

Claude Code 完成的步骤:

  1. git push -u origin feature/user-profile
  2. 调用 GitHub API 创建 PR,填写 title 和 body
  3. 通过 API 添加 reviewer
  4. 返回 PR 链接

整个过程不需要离开终端,也不用在浏览器里填表单。

用模板生成 PR Description

如果项目里有 .github/pull_request_template.md,直接告诉 Claude Code 按模板填:

> 按 PR 模板创建,测试这块写「单元测试 + 手动测试 iOS Safari 14」,
  风险评估写「涉及登录逻辑,建议先部署到 staging 验证」

它会把你说的内容映射到模板对应字段,其余字段从代码改动里自动提取。

PR 创建后的跟踪

有了 GitHub MCP,这些查询直接走 API,不用去浏览器刷页面:

> 我的 PR #234 CI 跑了多久?测试有没有过?
> PR #234 有什么 review 意见还没处理?
> PR #234 被 approve 了吗?帮我 merge 掉

分支管理

# 创建功能分支
> 从 main 创建一个新分支 feature/user-profile,然后切过去

# 查看分支状态
> 当前分支和 main 差了几个 commit?有没有冲突?

# 合并前检查
> 帮我 rebase 到最新的 main,如果有冲突就告诉我

实战场景:hotfix

线上出 bug 时,Claude Code 能帮你从排查到修复到提 PR 全流程搞定:

> 线上 /api/users 接口返回 500,这是错误日志:
> [粘贴日志]
> 帮我找到原因,修复,然后创建 hotfix PR

Claude Code 的执行流程:

  1. 分析错误日志,定位到具体的代码文件和行号
  2. 读取相关代码,理解上下文
  3. 找到 root cause 并修复
  4. 跑测试确认修复有效
  5. 创建 hotfix 分支、提交、推送、创建 PR

从发现 bug 到 PR ready,通常 5 分钟内完成。

解决 Merge Conflict

快速解决

> 帮我解决当前的 merge conflict

Claude Code 会读取冲突文件,理解两边的改动意图,选择合理的合并策略。对于复杂冲突,它会解释每处冲突的取舍理由,让你做最终决定。

详细工作流

实际的 merge conflict 处理分三步走:

第一步:搞清楚冲突来源

> git status 看一下,哪些文件有冲突?每个冲突大概是什么类型的改动?

Claude Code 会逐一分析冲突标记(<<<<<<< / ======= / >>>>>>>),判断是:

  • 同一行被两边都改了(真冲突,需要人工决策)
  • 两边改了不同函数(可以安全合并)
  • 一边删文件、另一边修改了同一文件(最复杂,需要理解业务意图)

第二步:解决每个冲突

对于简单情况,让它直接解决:

> src/components/Header.tsx 那个冲突,用 main 分支的版本
> src/utils/api.ts 那里两边的修改都要保留,帮我合并

对于复杂冲突,让它解释后你来决定:

> UserService.java 有三处冲突,帮我逐一分析,告诉我每处用哪边更合理,
  但别直接改,等我确认

第三步:验证合并结果

> 冲突都解决了,帮我跑一下测试,看看有没有引入新问题

常见陷阱

package-lock.json / yarn.lock 冲突:这类文件手工合并必出错。正确做法:

> package-lock.json 有冲突,帮我选一个版本 checkout,然后重新 npm install 生成

Claude Code 会 checkout 某一边的版本,再跑 npm install 重新生成 lockfile,结果一定是正确的。

Rebase 中途冲突:rebase 过程中遇到冲突会停下来,可以这样接着处理:

# rebase 停在某个 commit,告诉 Claude Code
> rebase 暂停了,当前冲突是什么情况?帮我解决,然后 git rebase --continue

Git Worktree 配合 Claude Code

为什么需要 worktree

开发时常见场景:你在 feature/checkout-v2 上改了一半,突然要去修一个生产 bug。常规做法是 git stash,切分支,改完再切回来、git stash pop。如果两个任务都需要 Claude Code 介入,两个 session 会互相干扰,stash/unstash 也容易出错。

git worktree 让你在同一个仓库里有两个独立的工作目录,各自对应不同分支,互不干扰。

基本用法

# 给 hotfix 任务开一个独立工作目录
git worktree add ../my-project-hotfix hotfix/payment-bug

# 在新工作目录里启动 Claude Code
cd ../my-project-hotfix
claude

两个终端窗口,两个 Claude Code session,分别处理不同任务,git 状态完全隔离。

让 Claude Code 帮你管理 worktree

> 用 git worktree 给我创建一个新工作目录处理 hotfix,
  分支名 hotfix/fix-cart-total,目录放在 ../jr-shop-hotfix

Claude Code 执行:

git worktree add -b hotfix/fix-cart-total ../jr-shop-hotfix main

任务完成后清理:

> worktree 任务搞完了,帮我合并回 main 然后删掉那个 worktree

Claude Code 依次执行:

# 提交 worktree 里的改动
git -C ../jr-shop-hotfix add .
git -C ../jr-shop-hotfix commit -m "fix: correct cart total calculation"

# 回到主目录合并
git checkout main
git merge hotfix/fix-cart-total

# 清理
git worktree remove ../jr-shop-hotfix
git branch -d hotfix/fix-cart-total

多 agent 并行任务

Claude Code 的 Agent SDK 里,isolation: "worktree" 选项会自动为每个子 agent 创建独立 worktree,任务结束后自动清理。这是在 CI / 自动化流水线里跑多个并发 agent 的推荐方式——每个 agent 有自己的文件系统视图,不会踩脚:

// 两个 agent 同时工作,互不干扰
const [refactorResult, testResult] = await Promise.all([
  claude.run("重构 UserService", { isolation: "worktree" }),
  claude.run("补充单元测试", { isolation: "worktree" }),
]);

详见第 8 章 Agent SDK 的隔离模式。

代码审查

让 Claude Code 在提交前帮你检查代码质量:

> review 一下我这次改的所有文件,看有没有问题

它会检查:

  • 逻辑错误和边界情况
  • 类型安全问题
  • 潜在的性能问题
  • 不符合项目规范的写法

安全机制

Claude Code 对 Git 操作的默认行为很保守:

  • 不会自动 push,修改都先到本地
  • 不会 force push 或 reset --hard
  • 不会跳过 pre-commit hook(--no-verify)
  • 敏感文件(.env、credentials)不会被 stage

这些限制确保你不会因为 AI 的一次操作搞坏远程仓库。如果某个操作确实需要 force push,你需要明确告诉它。

Author
Share or copy the link

Related learning resources

  • Vibe Coding Hub
  • Prompt engineering
← Previous articleClaude Code 从入门到实战 — 多文件编辑:Claude Code 的杀手锏Next article →Claude Code 从入门到实战 — Hooks 自动化:让 Claude Code 在对的时机干对的事

Related articles

🇦🇺测一下:袋鼠国码农能当FDE吗?

2026-12-01

Monash 研究:肠道酸度是膳食纤维降血压的关键;AI 搬运新闻冲击维州选举信息;MPAC 公布 2027 演出季

2026-12-01

Adelaide 物理学家获 $250,000 总理科学奖;全球葡萄酒消费六十年降四分之一;残障师范生实习障碍研究

2026-12-01

DVA-C03今日上线首发 · Google Cloud AI Agent认证完整解析 · AZ-401本月GA替代AZ-400

2026-12-01

Anthropic推迟下一代模型并调百人做安全,AWS推出AI办公三件套,Google让用户单独关掉AI训练

2026-12-01

GitHub Copilot 实战指南 — Copilot AI Code Review:30 秒让 AI 帮你审 PR,三档深度随需切换

2026-11-30
View all articles →

Done reading? Next steps

Not sure what to learn next? Tell us where you are

Tell us what you do now and where you want to go. See your gaps in skills, evidence, experience, expression and positioning, and what to work on first. No sign-in needed.

Compare with my situation
  • SkillAI Engineer Bootcamp13 weeks, 12 Theory + 13 Practice live classes. You build one Agent system across Context, RAG, Tools, Memory and production Evals. Built for Applied AI and Agent Engineer roles.See the program →
  • PositioningLearning roadmaps by roleFrontend, backend, data, AI and more, laid out stage by stage in the order to learn them.All roadmaps →
  • ExpressionTry an AI mock interviewPick a role and run a mock interview to practise explaining your experience and projects.Practise now →

Not sure what to do next?

Take this page's topic with you and see where your gaps are.

Compare with my situation
JR Academy
AI learning for the global Chinese community
BootcampsFree resourcesLearn AICareer coaching
精选推荐
AI Career Impact Map
Assess career exposure and explore transition paths and learning options
Popular tool
AI & Data Bootcamps
Build your skills through structured courses and hands-on projects
Popular courses
1:1 Career Coaching
Work with an experienced mentor on your resume and interview preparation
Career coaching
Custom Corporate Training
AI training tailored to your team
Business services
Popular tags
Vibe CodingAI codingCursorClaudeJob searchPromptFrontend developmentBackend development
Subscribe to updates

Receive AI learning resources, technical tutorials and career advice by email.

We respect your privacy and do not send spam.

Related certifications

Start with a few sample questions or a free chapter. The exam guide covers what the exam tests; the question bank lets you practise by exam domain.

Foundational

Claude Certified Architect – Foundations

CCAR-F

Sample questionsExam guide
Foundational

Claude Certified Developer – Foundations

CCDV-F

Question bankExam guide
Associate

Claude Certified Associate – Foundations

CCAO-F

Question bankExam guide