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

More than 1 year has passed since last update.

[Gitコマンド]git stashについて

0
Posted at

こんにちは!
開発現場でよく利用するGitコマンドを今後暫くは投稿していこうと思います。
まず手始めにgit stashについて纏めます。

git stashとは?

そもそもgit stashとは何か?
git stashは現在のブランチで開発中の作業を一時的に別の場所に保存をし、作業ディレクトリを綺麗な状態にします。

開発中のタスクで別のブランチでレビューがあった際、現在のブランチの作業内容に変更があった時には、ブランチの移動をすぐすることができません。
その際に役立つのがこのgit stahsです。これを一時的に別の場所に保存することで、ブランチの移動が可能になります。

git stashを実際にやってみよう。

現在の作業ディレクトリの変更を一時的に保存
git stash
メッセージ付きで変更を保存
git stash push -m "message"
保存されたすべてのスタッシュの一覧を表示
git stash list
最新のスタッシュを適用し、作業ディレクトリに戻す
git stash apply 
特定のスタッシュ(stash@{n})を適用
git stash apply stash@{n}
最新のスタッシュを適用し、その後スタッシュリストから削除
git stash pop
特定のスタッシュを適用し、その後スタッシュリストから削除
git stash pop stash@{n}
最新のスタッシュを削除
git stash drop
特定のスタッシュを削除
git stash drop stash@{n}
すべてのスタッシュを削除
git stash clear

まとめ

今日はgit stashについてまとめてみました。
基本的な操作ですが、実際の開発では結構便利で私自身利用頻度も多いです。

今後はこのような覚えていたら便利なGitコマンド操作をまとめていこうと思います。

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