0

I'm new to git and I've just done a mistake. A couple of days ago I did a git stash.

Let's say that my files were in status A. I kept on working on the files, updating them, without doing any commit.

Today I reached a new status, let's say B. Instead of doing a commit (my bad) I've just done again "git stash". I got this message:

"Saved working directory and index state WIP on master: cd8ba5c checkboxes created"

Here I'm confused, does it mean that the WIP has overwritten my last commit?

I was expecting just to save my data and keep on working. But it looks like the status has changed, and I lost part of my work.

I followed this : Undo a git stash

and did a "git stash pop" Dropped refs/stash@{0} (5165c71bf07f84a540496032828268c274e3f040)

ho do I get back to status B?

Thanks in advance!

  • 1
    `git stash` will, by default, save in the stash and clean the working tree so that it looks like you did not work since the last commit that is checked out.... to get that back from the stash, you run `git stash pop` which will apply the last item in the stash (it works like a stack, just in case). – eftshift0 Nov 18 '22 at 10:19
  • 1
    Then (after popping), the files must look the way they looked before you ran `git stash` by mistake. – eftshift0 Nov 18 '22 at 10:20
  • after "git stash pop" I didn't get back to my last status – Anna Setiva Nov 18 '22 at 10:24
  • 3
    It should..... unless something funky took place. Check the list of stashes `git stash list`. You can see what a stash item has (as a patch) with `git stash show -p stash@{some-number}`.... _and_ you can always reuse that stash ID that was shown in the terminal even if it was dropped (`git stash apply 5165c71bf07f84a540496032828268c274e3f040`). – eftshift0 Nov 18 '22 at 10:35
  • Not that this helps solve the immediate problem, but: since all `git stash` really does is make some commits (that are not on *any* branch), and those commits are hard to use correctly later, I recommend *avoiding* `git stash` in favor of just making ordinary commits (which are much easier to use correctly later). – torek Nov 22 '22 at 09:47

0 Answers0