ブランチを切り替えるのを忘れてしまったり、git pull
するのを忘れてしまったりと、
気をつけていてもやらかしてしまうことありますよね。
そんなときの強い味方、git stash
のコマンドの備忘録です。
コードを退避する
git stash
Saved working directory and index state WIP on master: ....
一覧を見る
git stash list
stash@{0}: WIP on master: 8af0e2a Merge branch ....
stash@{1}: WIP on master: c8743b8 Merge branch ....
stash@{2}: WIP on master: 49a6d3c Merge branch ....
stashを適用する(stashを適用後、残す場合)
git stash apply stash@{n}
stashを適用する(stashを適用後、削除する場合)
git stash pop stash@{n}
stashを削除する
git stash drop stash@{n}
Dropped refs/stash@{0} (2aaab50a6a629d3f9cac314f4491dac85231583f)