You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are a few stash variants that may also be helpful. The first option that is quite popular is the --keep-index option to the stash save command. This tells Git to not stash anything that you've already staged with the git add command.
v2で追加されたこの段落、「git stash save --keep-indexでstashすると、git addでインデックスに追加した内容はstashされないようにできる」という解釈で間違いないはず。けれど、このコマンドを実行すると、インデックスに追加されていた内容はstashされて、かつインデックスに残ったままになる。
$ git --version
git version 2.1.3
$ git stash list
$ vi README.md
$ git add README.md
$ git status
On branch markdown
Your branch is up-to-date with 'origin/markdown'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: README.md
$ git diff --staged
diff --git a/README.md b/README.md
index cd87828..f8f9682 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-README
+# README
## レビューするファイル
⬆️ Stash is empty. I editted one file and added that to index.
$ git stash save --keep-index
Saved working directory and index state WIP on markdown: 3f347db Apply upstream changes to markdown files
HEAD is now at 3f347db Apply upstream changes to markdown files
⬆️ Then I stashed the change using --keep-index option.
$ git stash list
stash@{0}: WIP on markdown: 3f347db Apply upstream changes to markdown files
$ git stash show stash@{0}
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
$ git stash show -p stash@{0}
diff --git a/README.md b/README.md
index cd87828..f8f9682 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-README
+# README
## レビューするファイル
⬆️ One stash is created, with the changes I staged earlier.
$ git status
On branch markdown
Your branch is up-to-date with 'origin/markdown'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: README.md
$ git diff --staged
diff --git a/README.md b/README.md
index cd87828..f8f9682 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-README
+# README
## レビューするファイル
⬆️ index is unchanged, which is the expected behavior of --keep-index option.
v2で追加されたこの段落、「
git stash save --keep-index
でstashすると、git add
でインデックスに追加した内容はstashされないようにできる」という解釈で間違いないはず。けれど、このコマンドを実行すると、インデックスに追加されていた内容はstashされて、かつインデックスに残ったままになる。ちなみに、ドキュメント には
とある。
なお、git version 2.1.3(On ubuntu) と git version 1.9.4.msysgit.1 で試して同じ挙動だった。以下はgit version 2.1.3のログ。
The text was updated successfully, but these errors were encountered: