คำสั่งสำหรับใช้งาน Git
คำสั่งสำหรับการตั้งค่าเริ่มต้น
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
//ตั้งค่า Default branch
git config --global init.defaultBranch main
//ตรวจสอบค่า Config
git config --list
คำสั่งพื้นฐาน
// คำสั่งสร้าง Repository
git init
//คำสั่งสำหรับ Add file ทั้งหมด
git add .
//คำสั่งสำหรับ save เก็บที่ local repository
git commit -m "ชื่อของการทำงาน"
//คำสั่งสำหรับดู history หรือประวัติการ commit ของ repository
git log
//คำสั่งสำหรับดูสถานะของ repository
git status
//คำสั่งสำหรับการย้อนกลับโค้ดที่เคยเขียนไว้
git restore <ชื่อไฟล์>
//คำสั่งสำหรับเปรียบเทียบ การเปลี่ยนแปลงของไฟล์ที่ได้แก้ไข
git diff
คำสั่งยกเลิกสิ่งที่เคย commit
// ย้อนกลับการเปลี่ยนแปลง และกลับไปยัง working directory (โค้ดเดิมไม่หาย)
git reset --mixed <commit>
//ย้อนกลับการเปลี่ยนแปลง และกลับมายัง Staged (โค้ดเดิมไม่หาย)
git reset --soft <commit>
//ย้อนกลับการเปลี่ยนแปลงพร้อมทั้งลบโค้ดเดิมที่เคยเขียนไว้ รวมถึงการ commit
git reset --hard <commit>
Last updated