1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

はじめに

git stashを初めて知ってからstashコマンドの便利さに気づいたため、アウトプットを兼ねてよく使うgit stashコマンドをまとめました。

git stashとは

変更した内容をコミットせずに一時的に退避することができるコマンド。

例) 「修正していたけれど一旦中断してコードレビューをしたい」「作業が中途半端だからコミットはしたくないけど一時的に保存したい」など

基本コマンド

  • 一時的に変更を退避させる
    git stash

  • stashから変更を削除し、退避させた変更を取り出す
    git stash pop

  • stashから変更を削除せずに退避させた変更を取り出す
    git stash apply

  • 名前付きでスタッシュする
    git stash save "メッセージ"

  • stashの一覧を表示
    git stash list

stashを削除したい時

  • stash@{0} を削除したい場合
    git stash drop stash@{0}

  • 一番上のstashを削除したい場合
    git stash drop

  • 全部の stash を一気に削除したい場合
    git stash clear

終わりに

今はまだわずかなコマンドしか覚えられていませんが、スムーズに全てのコマンドが使いこなせるように頑張ります!
git stashについてあまりよくわからない方や初学者の方の参考になりましたら幸いです。

1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?