git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Martin Häcker" <mhaecker@schwarz-online.org>
To: git@vger.kernel.org
Subject: git stash ; git stash pop unstages all staged changes
Date: Tue, 30 Jan 2018 11:05:00 +0100	[thread overview]
Message-ID: <454AAA27-B8D3-47F9-8E49-EC5415A26FCE@schwarz-online.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 2994 bytes --]

Hi there,

I just lost quite some work, because `git stash; git stash pop` doesn’t seem to understand the concept of the index correctly.

To reproduce:

— snip —
dwt@crest ~/Desktop % mkdir test
dwt@crest ~/Desktop % cd test
dwt@crest ~/Desktop/test % git init
Initialized empty Git repository in /Users/dwt/Desktop/test/.git/
dwt@crest ~/Desktop/test (git)-[master] % touch foo
dwt@crest ~/Desktop/test (git)-[master] % git add foo
dwt@crest ~/Desktop/test (git)-[master] % git commit -m "initial commit"
[master (root-commit) 893b428] initial commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 foo
dwt@crest ~/Desktop/test (git)-[master] % echo "bar" >> foo
dwt@crest ~/Desktop/test (git)-[master] % git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   foo

no changes added to commit (use "git add" and/or "git commit -a")
dwt@crest ~/Desktop/test (git)-[master] % git add foo
dwt@crest ~/Desktop/test (git)-[master] % git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	modified:   foo

dwt@crest ~/Desktop/test (git)-[master] % echo "baz" >> foo
dwt@crest ~/Desktop/test (git)-[master] % git diff
diff --git a/foo b/foo
index 5716ca5..e2994c5 100644
--- a/foo
+++ b/foo
@@ -1 +1,2 @@
 bar
+baz
dwt@crest ~/Desktop/test (git)-[master] % git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	modified:   foo

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   foo

dwt@crest ~/Desktop/test (git)-[master] % git stash
Saved working directory and index state WIP on master: 893b428 initial commit
dwt@crest ~/Desktop/test (git)-[master] % git status
On branch master
nothing to commit, working tree clean
dwt@crest ~/Desktop/test (git)-[master] % git stash pop
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   foo

no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (7a8d892120c0a231a529222dabeec1fd3594f514)
dwt@crest ~/Desktop/test (git)-[master] % git diff
diff --git a/foo b/foo
index e69de29..e2994c5 100644
--- a/foo
+++ b/foo
@@ -0,0 +1,2 @@
+bar
+baz

— snap —

What git stash does get right is that it does remove everything that is stashed from the current state of the repo, but what it doesn’t get right is restoring that state fatefully in `git stash pop`.

As a user, I would expect that `git stash pop` undoes the change that `git stash` inflicted.

Best Regards,
Martin Häcker

[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 235 bytes --]

             reply	other threads:[~2018-01-30 10:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-30 10:05 Martin Häcker [this message]
2018-01-30 19:57 ` git stash ; git stash pop unstages all staged changes Igor Djordjevic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=454AAA27-B8D3-47F9-8E49-EC5415A26FCE@schwarz-online.org \
    --to=mhaecker@schwarz-online.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).