LoginSignup
1
0

More than 1 year has passed since last update.

以下のようにgitで管理されてるhoge.txtfuga.txtがあるとしよう!
hoge.txtgit add済、fuga.txtはまだだ
スクリーンショット 0004-11-02 21.46.40.png

パターン1: 全部stashに保存したいんだ!

それなら話は簡単だ。git stashと打つだけで良い。

❯ git stash
Saved working directory and index state WIP on main: b4930c8 (commit message)

パターン2: addしたやつだけstashに保存したいんだ!

今回の話のメイン。
git-2.35で登場した新機能の--stagedオプションを使おう

以下スクショの通りなのだが、add済のもののみに絞ってstashすることが出来るのがgit stash [push] --stagedになる。(-Sでも同じ)スクリーンショット 0004-11-02 21.52.50.png

パターン3: addしてないやつだけstashに保存したいんだ!

このケースの場合は、--keep-indexオプションを使おう!(-kでも可)
スクリーンショット 0004-11-02 22.58.23.png

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