suggestion for git stash
Hi,
"git stash" has the effect of losing the distinction between untracked changes and changes in the index.
To reproduce:
- Clone the gnulib repository or of any repository with at least 2 files.
- Make changes to two files, say, README and NEWS.
$ git add README - $ git status now reports: # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: README # # Changed but not updated: # (use "git add <file>..." to update what will be committed) # # modified: NEWS #
- $ git stash
- $ git stash apply
- $ git status
now reports:
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
#
# modified: NEWS # modified: README
#
no changes added to commit (use "git add" and/or "git commit -a")
Could "git stash" be changed to memorize which changes were already scheduled for commit and which didn't?
Bruno
Isn't "stash apply --index" what you talk about?
Quoted 1 line · Junio C Hamano
Isn't "stash apply --index" what you talk about?
Not really:
$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: README # # Changed but not updated: # (use "git add <file>..." to update what will be committed) # # modified: NEWS # $ git stash Saved "WIP on master: 61135ee... Use check_PROGRAMS instead of noinst_PROGRAMS." HEAD is now at 61135ee... Use check_PROGRAMS instead of noinst_PROGRAMS. $ git stash apply --index error: No changes Conflicts in index. Try without --index.
(This is git version 1.5.3.1.)
I don't know what "git stash apply --index" does, since it's not documented.
Bruno
Hi,
Quoted 2 lines · Bruno Haible
I don't know what "git stash apply --index" does, since it's not documented.
It's documented in code ;-)
No, really, what it does is trying to reinstate not only the working tree's changes, but also the index' ones. However, this can fail, when you have conflicts (which are stored in the index, where you therefore can no longer apply the changes as they were originally).
Now that you know what --index is supposed to do, maybe you are nice enough to extend the documentation and post a patch?
Thanks,
Dscho
PATCH 1/1 git stash: document apply's --index switch
---
Quoted 2 lines · Johannes Schindelin
Now that you know what --index is supposed to do, maybe you are nice enough to extend the documentation and post a patch?
something like this?
VMiklos
Documentation/git-stash.txt | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
Documentation/git-stash.txt +6 -1
@@ -63,7 +63,7 @@ show [<stash>]:: it will accept any format known to `git-diff` (e.g., `git-stash show -p stash@\{1}` to view the second most recent stash in patch form). -apply [<stash>]:: +apply [--index] [<stash>]:: Restore the changes recorded in the stash on top of the current working tree state. When no `<stash>` is given, applies the latest
@@ -71,6 +71,11 @@ apply [<stash>]:: + This operation can fail with conflicts; you need to resolve them by hand in the working tree. ++ +If the `--index` option is used, then tries to reinstate not only the working +tree's changes, but also the index's ones. However, this can fail, when you +have conflicts (which are stored in the index, where you therefore can no +longer apply the changes as they were originally). clear:: Remove all the stashed states. Note that those states will then
Signature · 1 line
1.5.3.2.111.g5166-dirty
Quoted 1 line · Junio C Hamano
Isn't "stash apply --index" what you talk about?
It doesn't seem to be documented in Documentation/git-stash.txt, but seems to be the answer.
Signature · 1 line
Matthieu