git stash は、あなたのコミットされていない変更を一時的に保存し、ワーキングディレクトリをクリーンな状態に戻します。これにより、半完成の作業をコミットすることなく、コンテキストを切り替えて(例えば、別のブランチで緊急のバグを修正するなど)、後で変更を復元できます。
stashが解決する問題
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
