From 260a140bda4700d321e0cddab724466295f1309e Mon Sep 17 00:00:00 2001 From: yaame <969519545@qq.com> Date: Wed, 11 Sep 2019 05:01:59 +0000 Subject: [PATCH] fix case: switch stage & unstage files --- README.md | 8 ++++++-- README_zh-CN.md | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 121f4e3..fd291e8 100644 --- a/README.md +++ b/README.md @@ -606,11 +606,15 @@ Then, you will need to use the `e` option to manually choose which lines to add. ### I want to stage my unstaged edits, and unstage my staged edits -`stash` is a stack. So you can `stash` and `pop/apply --index n`(`apply` will keep it in stack). +In many cases, You should unstage all files and then pick file you want and commit it. +But assume that's what you want,You can create a temp commit to store your stage files, stage your unstaged files and stash them, Then, reset the temp commit and stash pop. ```sh +$ git commit -m "WIP" +$ git add . # also have untracked files $ git stash -$ git stash pop --index 1 +$ git reset HEAD^ +$ git stash pop --index 0 ``` ## Unstaged Edits diff --git a/README_zh-CN.md b/README_zh-CN.md index cbec526..d7cca7e 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -254,11 +254,15 @@ $ git add -N filename.x ### 我想把暂存的内容变成未暂存,把未暂存的内容暂存起来 -`stash`是个栈,我们只需要`stash`起来,然后`pop`/`apply --index x`即可(`apply`会保留在栈中)。 +多数情况下,你应该将所有的内容变为未暂存,然后再选择你想要的内容进行commit。 +但假定你就是想要这么做,这里你可以创建一个临时的commit来保存你已暂存的内容,然后暂存你的未暂存的内容并进行stash。然后reset最后一个commit将原本暂存的内容变为未暂存,最后stash pop回来。 ```sh +$ git commit -m "WIP" +$ git add . $ git stash -$ git stash pop --index 1 +$ git reset HEAD^ +$ git stash pop --index 0 ``` ## 未暂存(Unstaged)的内容