Skip to content

Commit f1a2195

Browse files
committed
add note about git stash pop --index 0
1 parent 4252773 commit f1a2195

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,9 @@ $ git reset HEAD^
617617
$ git stash pop --index 0
618618
```
619619

620+
NOTE 1: The reason to use `pop` here is want to keep idempotent as more as possible.
621+
NOTE 2: Your staged files will be marked as unstaged if you miss `--index` flag.[this link](https://stackoverflow.com/questions/31595873/git-stash-with-staged-files-does-stash-convert-staged-files-to-unstaged?answertab=active#tab-top) will explain it to you.
622+
620623
## Unstaged Edits
621624

622625
<a href="move-unstaged-edits-to-new-branch"></a>

README_zh-CN.md

+3
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ $ git reset HEAD^
265265
$ git stash pop --index 0
266266
```
267267

268+
注意1: 这里使用`pop`仅仅是因为想尽可能保持幂等。
269+
注意2: 假如你不加上`--index`你会把暂存的文件标记为为存储.这个[链接](https://stackoverflow.com/questions/31595873/git-stash-with-staged-files-does-stash-convert-staged-files-to-unstaged?answertab=active#tab-top) 解释得比较清楚。(不过是英文的,其大意是说,这是一个较为底层的问题,stash时会做2个commit,其中一个会记录index状态,staged的文件等东西,另一个记录worktree和其他的一些东西,如果你不在apply时加index,git会把两个一起销毁,所以staged里就空了)。
270+
268271
## 未暂存(Unstaged)的内容
269272

270273
<a href="move-unstaged-edits-to-new-branch"></a>

0 commit comments

Comments
 (0)