鶏口牛後な日々

心の赴くまま、やりたいことを仕事に。

git stash 基礎覚書

完全備忘です。

 

まだworking directoryにunstaged filesがある場合、git pull --rebaseやgit checkoutはできない。

そういう時に良いのが、working directoryのunstaged thingsを一時的に「退避」しておいてくれる、stashです。

 

git stash saveで退避します。(saveは省略可能)

 

git stash listでstashの一覧がみれます。

 

git stash apply <stash名>で、退避していたものを元に戻します。

 

git stash drop <stash名>で、削除します。

元に戻したものも、stashからは勝手には消えないので、こまめに消すようにしましょう。

 

git cleanでworking directoryにあるもの(stashしたもの含む)を全消しします。

 

 

参考:

Git - Stashing and Cleaning

変更を一時的に退避!キメろgit stash - Qiita