Week 11 of 12 📦

Git Workflows & GitHub Integration

การทำงานกับ Git และ GitHub

Git 工作流与 GitHub 集成

Git Workflows & GitHub Integration

1. Introduction / บทนำ / 简介

Claude Code มีการเชื่อมต่อ Git อย่างลึกซึ้ง สามารถคอมมิตการเปลี่ยนแปลง สร้างสาขา เปิด pull requests แก้ไขข้อขัดแย้ง และทำงานกับ GitHub ผ่าน gh CLI Git worktrees ช่วยให้พัฒนาขนานกันในสภาพแวดล้อมที่แยกจากกัน
Claude Code 具有深度的 Git 集成。它可以提交(commit)更改、创建分支(branch)、打开 pull request、解决冲突,并通过 gh CLI 与 GitHub 协作。Git worktrees 让你在相互隔离的环境中并行开发。
Claude Code has deep Git integration. It can commit changes, create branches, open pull requests, resolve conflicts, and work with GitHub through the gh CLI. Git worktrees allow parallel development in isolated environments.

Fun Facts / ข้อเท็จจริงที่น่าสนใจ / 趣味知识

  • Claude never force-pushes to main unless explicitly asked.
  • /diff opens an interactive viewer for all your changes.
  • Worktrees let subagents work on separate branches simultaneously.
The red Git logo: a branching diagram and the word git
The Git logo: a branch that forks and merges. — Photo: Jason Long, CC BY 4.0, via Wikimedia Commons

2. Vocabulary / คำศัพท์ / 词汇

Click a card to flip it. คลิกการ์ดเพื่อพลิก 点击卡片翻面。

commit
คอมมิต
提交
To save changes to the repository
branch
สาขา
分支
A separate line of development
merge
รวม
合并
To combine two branches together
pull request
พูลรีเควสต์
拉取请求
A request to merge changes
push
พุช
推送
To upload commits to a remote server
clone
โคลน
克隆
To copy a repository to your computer
repository
รีโพซิทอรี
仓库
A storage location for code
staging
สเตจจิง
暂存
Preparing files for a commit
diff
ดิฟฟ์
差异
The difference between file versions
review
รีวิว
审查
To examine code changes before merging
conflict
ข้อขัดแย้ง
冲突
When two changes overlap in the same file
remote
รีโมต
远程仓库
A server hosting the repository

3. Grammar Focus / ไวยากรณ์ / 语法焦点

Sequence Words (first, then, next, finally) / คำบอกลำดับ (first, then, next, finally) / 顺序词(first、then、next、finally)

Thai:
คำบอกลำดับจัดลำดับขั้นตอน: 'first' (เริ่มต้น), 'then/next' (ขั้นตอนกลาง), 'after that' (ภายหลัง), 'finally' (สุดท้าย) ตัวอย่าง: 'First, create a branch. Then, make your changes. Finally, open a pull request.'
中文:
顺序词用来给步骤排序:'first'(开始),'then/next'(中间步骤),'after that'(之后),'finally'(最后)。例如:'First, create a branch.'(首先,创建一个分支。)'Then, make your changes.'(然后,进行修改。)'Finally, open a pull request.'(最后,打开一个 pull request。)
English:
Sequence words order steps: 'first' (beginning), 'then/next' (middle steps), 'after that' (later), 'finally' (end). Example: 'First, create a branch. Then, make your changes. Finally, open a pull request.'
ก่อนอื่น สร้างสาขาใหม่
首先,创建一个新分支。
First, create a new branch.
จากนั้น คอมมิตการเปลี่ยนแปลง
然后,提交你的更改。
Then, commit your changes.
สุดท้าย เปิด pull request
最后,打开一个 pull request。
Finally, open a pull request.

Section Check 1

What does /diff show?

/diff แสดงอะไร?

/diff 显示什么?

Section Check 2

Which word means 'at the end'?

คำใดหมายถึง 'สุดท้าย'?

哪个词的意思是“在最后”?

Section Check 3

What creates an isolated git copy?

อะไรสร้างสำเนา git ที่แยกจากกัน?

什么可以创建一个隔离的 git 副本?

4. Tutorial Steps / ขั้นตอนการเรียนรู้ / 教程步骤

1
Ask Claude to commit / ขอให้ Claude คอมมิต / 让 Claude 提交
Say: 'Commit my changes with a descriptive message' — Claude stages and commits.

How to do it

  • Make some changes first, then say: Commit my changes with a descriptive message.
  • Claude runs git status and git diff, writes a message, and shows the commit command before running it.
  • You approve the command like any other action.
2
Create a branch / สร้างสาขา / 创建分支
Say: 'Create a new branch called feature/login' — Claude runs git checkout -b.

How to do it

  • Say: Create a new branch called feature/login.
  • Claude runs git checkout -b feature/login.
  • New commits now land on the branch — main stays safe.
3
Open a pull request / เปิด pull request / 打开 pull request
Say: 'Create a PR for this branch' — Claude uses gh pr create.

How to do it

  • You need a GitHub repository and the gh CLI signed in (gh auth login).
  • Say: Create a PR for this branch — Claude pushes and runs gh pr create.
  • You get the PR URL in the chat; review and merge on GitHub.
4
View changes with /diff / ดูการเปลี่ยนแปลงด้วย /diff / 用 /diff 查看更改
Type /diff to see all uncommitted changes in an interactive viewer.

How to do it

  • Type /diff to open an interactive viewer of all uncommitted changes.
  • Move between files with the arrow keys.
  • Make it a habit: check /diff before every commit.
5
Use worktrees / ใช้ worktrees / 使用 worktrees
Run claude --worktree feature-name for isolated parallel development.

How to do it

  • Run claude --worktree feature-name to work in an isolated copy of the repo.
  • Two tasks can run in parallel without stepping on each other's files.
  • Merge the worktree's branch back when the task is done.

5. Hands-On Activity / กิจกรรมลงมือทำ / 动手练习

แบบฝึกหัด: แก้ไขโค้ด ขอให้ Claude คอมมิต สร้างสาขา และอธิบาย git workflow ทั้งหมดโดยใช้คำบอกลำดับ
练习:修改一处代码,让 Claude 提交它、创建一个分支,并用顺序词描述完整的 git 工作流程。
Practice: Make a code change, ask Claude to commit it, create a branch, and describe the full git workflow using sequence words.

Step by step

  1. Change one file (add a comment is enough).
  2. Say: Create a branch called practice/git-workflow.
  3. Say: Commit my change with a good message — review, then approve.
  4. Type /diff — it should now be clean. Finally, describe what you did using first, then, next, finally.

✓ You did it right if: git log shows your commit sitting on the new branch.

📜 A complete git workflow session / ตัวอย่างคำตอบ / 示例答案
# FIRST, make a branch
> Create a branch called practice/git-workflow
* Bash(git checkout -b practice/git-workflow)  Allow? > y

# THEN, change something and commit it
> Commit my change with a good message
* Bash(git add app.py)
* Bash(git commit -m "Fix greeting typo in app.py")  Allow? > y

# NEXT, check that everything is clean
> /diff
  (no uncommitted changes)

# FINALLY, share it
> Push this branch and open a PR
* Bash(git push -u origin practice/git-workflow)
* Bash(gh pr create --title "Fix greeting typo")  Allow? > y
  https://github.com/you/your-repo/pull/7

6. Reference Table / ตารางอ้างอิง / 参考表

Command / ToolEnglishภาษาไทย中文
commitSave changes to repoบันทึกการเปลี่ยนแปลง把更改保存到仓库
branchCreate parallel development lineสร้างสายการพัฒนาขนาน创建并行的开发线
pull requestRequest to merge changesขอรวมการเปลี่ยนแปลง请求合并更改
/diffInteractive change viewerดูการเปลี่ยนแปลงแบบโต้ตอบ交互式查看更改
--worktreeIsolated git environmentสภาพแวดล้อม git ที่แยกจากกัน隔离的 git 环境

7. Interactive Lab / ห้องทดลอง / 互动实验室

Grow a real branch graph, then prove you know the workflow order. / สร้างกราฟ git แล้วเรียงลำดับขั้นตอนให้ถูก / 构建 git 分支图,再排出正确的流程顺序

Build a git history. Commit, branch, switch, merge — watch the graph grow.

8. Summary / สรุป / 总结

Claude Code จัดการ git workflows: คอมมิต สาขา PRs และ worktrees คำบอกลำดับ (first, then, next, finally) จัดระเบียบกระบวนการหลายขั้นตอนอย่างชัดเจน
Claude Code 管理 git 工作流程:commit、branch、PR 和 worktree。顺序词(first、then、next、finally)能把多步骤过程清晰地组织起来。
Claude Code manages git workflows: commits, branches, PRs, and worktrees. Sequence words (first, then, next, finally) organize multi-step processes clearly.

Homework / การบ้าน / 作业

1. ฝึก git workflow เต็มรูปแบบกับ Claude
2. สร้าง PR โดยใช้ Claude Code
3. เขียนคู่มือ 5 ขั้นตอนโดยใช้คำบอกลำดับ
1. 和 Claude 一起练习完整的 git 工作流程。
2. 使用 Claude Code 创建一个 PR。
3. 用顺序词写一份 5 步指南。
1. Practice a full git workflow with Claude.
2. Create a PR using Claude Code.
3. Write a 5-step guide using sequence words.