LoginSignup
1
4

More than 5 years have passed since last update.

一時的に作業内容を退避して別ブランチで作業したい時のgit stashコマンドです。

Posted at

はじめに

別のブランチに切り替えることになりたいが、現在の作業内容はまだコミットしたくないとき、git stashで、変更をいったん隠すことができます。

使い方

一時的に退避

$ git stash

わかりやすくなるため、コメントを入れることができます
$ git stash " コメント"

退避した内容を確認

$ git stash list

stash@{0}: WIP on <branch-name>: <lastest commit>
stash@{1}: WIP on <branch-name>: <lastest commit>
stash@{2}: WIP on <branch-name>: <lastest commit>

変更内容を確認するコマンド
$ git stash list -p

退避した物の詳細内容を確認するコマンド
$ git stash show stash@{0}

退避した内容を適用

$ git stash apply stash@{0}

適用して削除したい時
$ git stash pop stash@{0}

退避した物をdropして消去

$ git stash drop stash@{0}

退避した物を全削除するコマンド
$ git stash clear

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4