คอร์สทั้งหมด

Developer Tools

Git สำหรับมือใหม่

เริ่มจาก commit แรก ฝึก branch, merge และแก้ conflict แล้วส่งโค้ดขึ้น GitHub

เริ่มต้น8 บทเรียนเรียนฟรี

บันทึกการเปลี่ยนแปลงครั้งแรก

Git เก็บประวัติการเปลี่ยนแปลงของโปรเจกต์ในเครื่อง ส่วน GitHub เป็นบริการเก็บ repository ออนไลน์ คุณเริ่มเรียนบทนี้ได้โดยไม่ต้องมีบัญชี GitHub

เปิด PowerShell ในโฟลเดอร์ที่เก็บงานทดลอง ตรวจว่า git --version แสดงเวอร์ชัน ถ้ายังไม่มี Git ให้ติดตั้งจาก เว็บไซต์ Git จากนั้นสร้างโฟลเดอร์ใหม่แล้วทำ commit แรก

mkdir git-practice
cd git-practice
git init -b main
git config --local user.name "Git Learner"
git config --local user.email "learner@example.com"

Set-Content -Path README.md -Value '# Git practice'
Set-Content -Path notes.md -Value '# Learning notes'
git status
git add README.md notes.md
git status
git commit -m "Add README and learning notes"
git log --oneline
  • Working tree คือไฟล์ที่กำลังแก้อยู่
  • Staging area คือชุดการเปลี่ยนแปลงที่เลือกด้วย git add เพื่อเก็บใน commit ถัดไป
  • Commit คือภาพสถานะที่บันทึกแล้ว ดูย้อนกลับได้ด้วย git log

ชื่อตัวอย่างถูกตั้งเฉพาะ repository นี้ เปลี่ยนเป็นชื่อที่ต้องการก่อนสร้าง commit ของคุณ

ลองทำ รัน git status หลัง commit แล้วเทียบกับสถานะก่อน git add และก่อน commit

บทเรียน Git อย่างเป็นทางการ