Skip to content

Initialization and Setup

คำสั่งคำอธิบาย
git initทำให้สามารถใช้งาน git ได้
git configกำหนดค่าใน .gitconfig
git ignoreทำให้ไฟล์นั้นใช้ git ไมได้
git prune

Commit Management

ข้อควรรู้

HEAD => คือ current commit ที่กำลังทำงานอยู่

คำสั่งคำอธิบาย
git commitบันทึกการเปลี่ยนแปลง
git squashรวมหลาย commit เข้าด้วยกัน (ผ่าน rebase)
git revertย้อนกลับการเปลี่ยนแปลงจาก commit โดยการสร้าง commit ใหม่ที่ทำให้การเปลี่ยนแปลงนั้นหายไป
git resetย้าย current commit(HEAD) ไปยัง other commit
git cherry-pickนำ commit จาก branch อื่นมารวมใน branch ปัจจุบัน
git stashเก็บการเปลี่ยนแปลงที่ยังไม่ได้ commit ไว้ชั่วคราว
git reflogดูประวัติการเคลื่อนไหวของ HEAD

Branch Management

คำสั่งคำอธิบาย
git branchแสดงรายการ branch หรือสร้าง branch ใหม่
git worktreeจัดการกับ worktree ที่แยกจาก repository หลัก
git checkoutเปลี่ยนไปยัง branch อื่น หรือย้อนกลับไฟล์ที่เปลี่ยนแปลง
git mergeรวมการเปลี่ยนแปลงจาก branch อื่นเข้ากับ branch ปัจจุบัน
git rebaseย้ายหรือรวม commit จาก branch หนึ่งไปยังอีก branch หนึ่ง
git tagสร้างหรือแสดง tags ซึ่งเป็นจุดอ้างอิงในประวัติ commit
git show
git log
git blame

Remote Management

คำสั่งคำอธิบาย
git remoteจัดการกับ remote repositories เช่น เพิ่ม ลบ หรือแสดง remote
git pullดึงการเปลี่ยนแปลงจาก remote repository และ merge เข้ากับ branch ปัจจุบัน
git pushส่งการเปลี่ยนแปลงจาก local repository ไปยัง remote repository
git fetchดึงการเปลี่ยนแปลงจาก remote repository โดยไม่ทำการ merge
git cloneคัดลอก repository ทั้งหมดจาก remote repository มายังเครื่องของคุณ

Submodules

คำสั่งคำอธิบาย
git submoduleจัดการกับ submodules ซึ่งเป็น repository ที่ฝังอยู่ใน repository หลัก
git pruneลบการอ้างอิงที่ไม่มีการใช้งานใน repository

Other Commands

คำสั่งคำอธิบาย
git logแสดงประวัติ commit
git blameแสดงข้อมูลเกี่ยวกับการเปลี่ยนแปลงในแต่ละบรรทัดของไฟล์

Released under the MIT License