雑多なブログ

音楽や語学、プログラム関連の話題について書いています

git stash の使い方

スタッシュ

普通にスタッシュ

git stash

untrackファイルも含めてスタッシュ

git stash -u

unstageファイルも含めてスタッシュ

git stash -k

スタッシュする・その2

git stash save

メッセージを付けてスタッシュ

git stash save "message"

スタッシュの一覧を出力

git stash list

スタッシュしたファイルのリストを出力

git show N

もしくは

git show stash@{N}

スタッシュの取り出し

最新のスタッシュを適用して、スタッシュの情報は削除

git stash pop

指定したスタッシュを適用して、スタッシュの情報は削除

git stash pop stash@{N}

もしくは

git stash N

スタッシュを適用し、スタッシュの情報も残す

git stash apply stash@{N}

もしくは

git stash apply N

スタッシュの削除

最新のスタッシュを削除

git drop

指定したスタッシュを削除

git drop stash@{N}

もしくは

git drop N

全てのスタッシュをクリア

git stash clear

※実行注意