Branch,Merge,Stash

คำสั่งเกี่ยวกับ Branch

// คำสั่งแสดง branch ที่มีทั้งหมดใน repo
git branch

// สร้าง branch ใหม่
git branch <ชื่อ>

// เปลี่ยน branch
git checkout <ชื่อ>

// เปลี่ยนชื่อ branch
git branch -m <ชื่อเดิม> <ชื่อใหม่>

// ลบ branch 
git branch -d <ชื่อ>

คำสั่งเกี่ยวกับ Merge

// การ merge
git merge <ชื่อ>  ***ต้อง checkout ไปอยู่ใน branch ที่ต้องการก่อน***
หรือ
git merge --no-ff <ชื่อ>   ***จะคงประวัติของ branch ที่ merge ไปด้วย***

คำสั่งเกี่ยวกับ Stash

// คำสั่งสำหรับการเก็บสิ่งที่ทำอยู่ไว้ แล้วทำส่วนอื่นก่อน
***ก่อนใช้ stash ต้อง git add . ก่อนเสมอ***
git stash

// ดูรายการ stash
git stash list

//เรียกสิ่งที่เก็บไว้กลับมาทำงานต่อ
git stash pop 

Last updated