สำหรับนักเรียนที่ไม่เคยใช้ Git มาก่อน — อ่าน 15 นาที พอใช้งานใน workshop ได้
ลองนึกภาพว่าทีมกำลัง train AI:
- Model V1 → accuracy 70%
- ลองแก้ → accuracy เหลือ 50% 😱
- "อยาก revert กลับไป V1!"
Git คือเครื่องมือที่ช่วย:
- ✅ บันทึก state ของโค้ด/ข้อมูล แต่ละช่วงเวลา (เรียกว่า commit)
- ✅ ย้อนกลับไป state ก่อนหน้าได้
- ✅ ทำงานร่วมกันหลายคนโดยไม่ทับโค้ดกัน
GitHub คือ cloud ที่เก็บ Git repository ของทีม
| คำ | ความหมาย | อธิบายแบบบ้านๆ |
|---|---|---|
| Repository (Repo) | โฟลเดอร์โปรเจกต์ที่ติดตาม version | "ตู้เก็บงาน" |
| Commit | บันทึก snapshot ของงาน | "ถ่ายรูปงาน ณ ตอนนี้" |
| Push | อัพโหลด commit ขึ้น GitHub | "ส่งงานเข้า cloud" |
| Pull | ดาวน์โหลดจาก GitHub | "ดึงงานล่าสุดมา" |
| Fork | คัดลอก repo คนอื่นเป็นของตัวเอง | "ก๊อปต้นแบบมา" |
| Clone | ดาวน์โหลด repo ลงเครื่อง | "เอา repo ลง laptop" |
| Branch | สาขางาน (เริ่มที่ main) |
"ทำหลาย version พร้อมกัน" |
| Pull Request (PR) | ขอ merge งานเข้า main | "ขอเอางานของฉันเข้าหลัก" |
ทุกคนในทีมต้องมีบัญชี GitHub:
- ไป https://github.com/signup
- ใช้ email + username ที่จำง่าย
- แนะนำ: ใช้ email จริง ไม่ใช่ใช้ครั้งเดียวแล้วทิ้ง
Windows: ดาวน์โหลด https://git-scm.com/download/win
Mac: เปิด Terminal → xcode-select --install
Linux: sudo apt install git
ทดสอบ:
git --version
# git version 2.x.xgit config --global user.name "Your Name"
git config --global user.email "your@email.com"- ไปที่ repo ของ workshop (ลิงก์ที่ทีมใช้อยู่)
- เปิดโฟลเดอร์
templates/team-repo-template/ - สร้าง repo ใหม่ใน account ของทีมชื่อ
edge-ai-team-XX(XX = เลขทีม) - คัดลอกไฟล์จาก template ไปใส่ repo ทีม
- ตั้ง repo เป็น Public เพื่อให้เพื่อนร่วมทีมและ TA เห็นความคืบหน้าได้
ถ้ามี template repo แยกต่างหากอยู่แล้ว ให้ใช้ repo นั้นแทนโฟลเดอร์ template ใน workshop repo นี้
# เปลี่ยน URL ให้ตรงกับ repo ของทีม
git clone https://github.com/your-team/edge-ai-team-XX.git
cd edge-ai-team-XX# ดูว่ามีอะไรเปลี่ยนบ้าง
git status
# Add ไฟล์ที่อยากบันทึก
git add .
# หรือเฉพาะไฟล์: git add worksheets/W1-class-design.md
# Commit พร้อมข้อความ
git commit -m "feat: define 3 classes for Track A motion sensor"
# Push ขึ้น GitHub
git pushgit pullนี่คือส่วนสำคัญที่สุดของหัวข้อ Debug & Explain (5 คะแนน)
<type>: <สิ่งที่ทำ> เพราะ <เหตุผล>
| Type | ใช้เมื่อ |
|---|---|
feat |
เพิ่ม feature ใหม่ |
fix |
แก้ bug |
data |
เพิ่ม/แก้ dataset |
train |
train model ใหม่ |
docs |
แก้เอกสาร |
test |
เพิ่ม test |
refactor |
rearrange โค้ดไม่ได้เปลี่ยนผล |
❌ แย่:
update
fix
test123
asdf
✅ ดี:
feat: เพิ่ม class "ล้ม" เพราะโจทย์ต้องการ fall detection
data: เก็บข้อมูล "เดิน" เพิ่ม 30 samples เพราะ V1 confusion สูง
train: ลด model size จาก small เป็น nano เพราะ memory error บน UNO Q
fix: แก้ Qwiic cable ปกติ การต่อ Movement ก่อน Pixels ตามลำดับ I2C
docs: เพิ่มผลการทดสอบ V1 vs V2 ลง docs/v1-vs-v2.md
# สร้าง branch ใหม่
git checkout -b feat/add-fall-class
# ทำงาน...
git add .
git commit -m "feat: เพิ่ม class ล้ม"
git push -u origin feat/add-fall-classแล้วบน GitHub:
- กด Compare & pull request
- เพิ่มคำอธิบายสั้น ๆ
- กด Create pull request
- ให้เพื่อนในทีม review + approve
- Merge
ทำไมถึงสำคัญ? Pull Request = หลักฐาน Participation & Collaboration (5 คะแนน)
# ดูสถานะ
git status
# ดู history
git log --oneline
# Add ไฟล์
git add <file> # ไฟล์เดียว
git add . # ทั้งหมด
# Commit
git commit -m "message"
# Push/Pull
git push
git pull
# สร้าง/เปลี่ยน branch
git checkout -b new-branch
git checkout main
# Undo (ยังไม่ commit)
git restore <file>
# ดู remote
git remote -v# ลบไฟล์ออกจาก git แต่เก็บใน folder
git rm --cached big-file.zip
echo "big-file.zip" >> .gitignore
git commit -m "fix: ลบไฟล์ใหญ่ออกจาก tracking"git pull --rebase
git pushไม่เป็นไร — กลับมาเปิดใหม่ Git ยังจำ state ไว้ ทำ git status ดูได้
git blame <file>- Interactive Tutorial: https://learngitbranching.js.org/
- GitHub Docs: https://docs.github.com/en/get-started
- Pro Git Book (ฟรี): https://git-scm.com/book
- ทุกคนมี GitHub account
- สร้าง repo ทีมจาก template
- ทุกคน commit อย่างน้อย 3 ครั้ง
- อย่างน้อย 1 Pull Request ที่ทีมรีวิวกัน
- Commit message ตาม format
- Push ก่อนเลิก workshop