ข้ามไปเนื้อหาหลัก

git stash push -m ช่วยให้จำได้ว่า stash ไหนคืออะไร

stash โดยไม่ใส่ชื่อคือหายนะเมื่อมีหลาย stash — -m ช่วยได้

เคย stash งานไว้หลายชั้นแล้วไม่รู้ว่า stash@{2} คืออะไร?

ใช้ -m ใส่ชื่อ:

git stash push -m "wip: refactor header component"
git stash push -m "experiment: try new color scheme"

ดูรายการพร้อมชื่อ:

git stash list
# stash@{0}: On master: experiment: try new color scheme
# stash@{1}: On master: wip: refactor header component

เรียก stash กลับด้วย index ที่รู้แล้วว่าคืออะไร:

git stash pop stash@{1}  # เอา wip: refactor header กลับมา

เทคนิคเล็กๆ แต่ช่วยได้มากเมื่อต้องสลับ context บ่อยหรือทิ้ง stash ไว้ข้ามวัน