git stash 临时保存你的未提交更改并将你的工作目录恢复为干净状态——这样你可以切换上下文(例如在另一个分支上修复紧急 bug),而无需提交未完成的工作,然后稍后恢复这些更改。
为什么这很重要
You're mid-work with uncommitted changes, but need to switch context urgently:
→ switch branches? Git may refuse (uncommitted changes would conflict) or carry
them along messily
→ commit half-done work? No — it's not ready (pollutes history)
→ STASH saves your changes aside, giving you a clean working directory to switch.
使用 stash
git stash
git stash push -m
git stash list
git stash pop
git stash apply
git stash apply stash@{1}
git stash drop stash@{0}
git stash clear
