1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

よく使うgit stash系コマンド

Posted at

stashの小ネタです。ふと思い出せないときがあるので、備忘録兼ねて。

gitで作業中に差し込みのタスクが入ってきたときなどに使う、 git stash コマンド。

よく使うコマンドをリストアップします。

作業中のファイルを退避

$ git stash

退避したリストを確認

$ git stash list
stash@{0}: WIP on <branch名>: <コミットハッシュ> <コミットメッセージ>
stash@{1}: WIP on <branch名>: <コミットハッシュ> <コミットメッセージ>
...

退避した内容を確認する

$ git stash show <stash名>
# ex: git stash show stash@{0}
# stashしたファイルのdiffが見れる

指定した退避内容を全て適用する(適用した内容を破棄しない)

$ git stash apply <stash名>

最新の退避内容を全て適用する(適用した内容は破棄される)

$ git stash pop

指定した退避内容から、一部のファイルのみ適用する

指定したstash名に退避されているファイルの中から、指定したファイルの退避内容を適用する

$ git checkout <stash名> <ファイル名>
1
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?