การ Stage และ Commit ไฟล์

Introduction to Git

George Boorman

Curriculum Manager

Git Workflow

  • แก้ไขและบันทึกไฟล์ในเครื่อง

 

  • เพิ่มไฟล์ไปยัง Staging Area ของ Git
    • ติดตามสิ่งที่มีการแก้ไข

 

  • Commit ไฟล์
    • Git จะบันทึก Snapshot ของไฟล์ ณ จุดนั้น
    • ช่วยให้เปรียบเทียบและย้อนกลับไฟล์ได้
Introduction to Git

Staging กับ Committing

Staging Area

 

จดหมายที่กำลังใส่ซอง

การทำ Commit

 

ตู้ไปรษณีย์

Introduction to Git

การเพิ่มไฟล์ไปยัง Staging Area

  • เพิ่มไฟล์เดียว
git add README.md

 

  • เพิ่มไฟล์ที่แก้ไขทั้งหมด
git add .
  • . = ไฟล์ทั้งหมดในไดเรกทอรีปัจจุบันและไดเรกทอรีย่อย
Introduction to Git

การทำ Commit

git commit -m "Adding a README."
[main cb33c18] Adding a README.
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
  • -m ช่วยให้เพิ่มข้อความ Log โดยไม่ต้องเปิด Text Editor
  • ข้อความ Log มีประโยชน์สำหรับการอ้างอิง
  • Best Practice = สั้นและกระชับ
Introduction to Git

มาฝึกกันเถอะ!

Introduction to Git

Preparing Video For Download...