Introduction to Git
George Boorman
Curriculum Manager, DataCamp
ls, cdgit initgit add ., git commit -mวิธีที่ Git จัดเก็บข้อมูล
git log
3--since--untilgit show c27fa856

| คำสั่ง | ฟังก์ชัน |
|---|---|
git diff report.md |
แสดงความแตกต่างระหว่างไฟล์ที่ยังไม่ได้ stage กับ commit ล่าสุด |
git diff --staged report.md |
แสดงความแตกต่างระหว่างไฟล์ที่ stage แล้วกับ commit ล่าสุด |
git diff 35f4b4d 186398f |
แสดงความแตกต่างระหว่าง 2 commit โดยใช้ commit hash |
git diff HEAD~1 HEAD~2 |
แสดงความแตกต่างระหว่าง 2 commit โดยใช้ HEAD syntax |
| คำสั่ง | ผลลัพธ์ |
|---|---|
git revert HEAD |
ย้อนกลับไฟล์ทั้งหมดจาก commit ที่ระบุ |
git revert HEAD --no-edit |
ย้อนกลับโดยไม่เปิด text editor |
git revert HEAD -n |
ย้อนกลับโดยไม่สร้าง commit ใหม่ |
git checkout HEAD~1 -- report.md |
ย้อนกลับไฟล์เดียวจาก commit ก่อนหน้า |
git restore --staged report.md |
นำไฟล์เดียวออกจาก staging area |
git restore --staged |
นำไฟล์ทั้งหมดออกจาก staging area |
Introduction to Git