{"thread":{"id":"9996","subject":"My stash wants to delete all my files","startedAt":"2007-09-24T13:12:15Z","lastAt":"2007-09-25T10:41:50Z","messageCount":6,"participants":["Jonathan del Strother","Junio C Hamano","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"53915","messageId":"5A9D6E3B-7B0E-4414-9AFB-C1C8B2EE6A9D@steelskies.com","threadId":"9996","inReplyTo":null,"subject":"My stash wants to delete all my files","fromName":"Jonathan del Strother","fromEmail":"maillist@steelskies.com","sentAt":"2007-09-24T13:12:15Z","receivedAt":"2007-09-24T13:12:15Z","isPatch":false,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"Heya,\nI've run into a problem with git stash.  I suspect that I've already  \nlost the work that I tried to stash, but would like to know where I  \nwent wrong.\n\nI had some work in progress, wanted to check something from my last  \ncommit, and typed \"git stash\".  I forgot to \"git stash apply\"  \nimmediately afterward, and carried on doing some more work related to  \nthe stashed code.  I realized that I'd got a stash that I wanted to  \napply, and tried to restore it.\nWhile trying to restore it, I typed \"git stash --apply\", which  \nactually created a new stash named \"--apply\".  Ooops.  Anyway, the  \nreal problem is :\n\n$ git stash list\nstash@{0}: On master: --apply\nstash@{1}: WIP on master: 09e3c30... Better handling of cell sizes in  \nthe grid\n\n$ git stash show stash@{1}\n  .gitignore                            |    3 -\n  AppController.h                       |   10 -\n  AppController.m                       |   30 -\n  English.lproj/InfoPlist.strings       |  Bin 202 -> 0 bytes\n  English.lproj/MainMenu.xib            | 2560  \n---------------------------------\n  GLScene.h                             |   21 -\n  GLScene.m                             |  287 ----\n  Info.plist                            |   28 -\n  LayoutManager.h                       |   19 -\n  LayoutManager.m                       |  118 --\n  OpenGLTests.xcodeproj/project.pbxproj |  323 -----\n  OpenGLTests_Prefix.pch                |   10 -\n  TheWall.h                             |   28 -\n  TheWall.m                             |   99 --\n  UserImage.h                           |   17 -\n  UserImage.m                           |  111 --\n  Utilities.h                           |   38 -\n  Utilities.m                           |   89 --\n  main.m                                |   14 -\n  19 files changed, 0 insertions(+), 3805 deletions(-)\n\n\nHmm.  Looks like it's trying to delete all of my versioned files.   \n\"git stash apply stash@{1}\" confirms this.   Obviously that's not what  \nI tried to stash - my WIP when I stashed was a few additions, a couple  \nof new unversioned files, and moving a few lines of code from one file  \nto another.\n\nAny ideas what happened there?  I can't seem to reproduce the problem  \nin a test repository.\n\nCheers,\nJon\n"},{"id":"53956","messageId":"7vabrb8rin.fsf@gitster.siamese.dyndns.org","threadId":"9996","inReplyTo":"5A9D6E3B-7B0E-4414-9AFB-C1C8B2EE6A9D@steelskies.com","subject":"Re: My stash wants to delete all my files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-25T01:26:08Z","receivedAt":"2007-09-25T01:26:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan del Strother <maillist@steelskies.com> writes:\n\n> $ git stash list\n> stash@{0}: On master: --apply\n> stash@{1}: WIP on master: 09e3c30... Better handling of cell sizes in\n> the grid\n>\n> $ git stash show stash@{1}\n>  ...\n>  19 files changed, 0 insertions(+), 3805 deletions(-)\n>\n> Hmm.  Looks like it's trying to delete all of my versioned files.\n> \"git stash apply stash@{1}\" confirms this.   Obviously that's not what\n> I tried to stash - my WIP when I stashed was a few additions, a couple\n> of new unversioned files, and moving a few lines of code from one file\n> to another.\n>\n> Any ideas what happened there?  I can't seem to reproduce the problem\n> in a test repository.\n\nThere are two possibilities that I can think of offhand, neither\nof them is about git-stash but about the state you ran stash\nfrom.\n\nWhenever anybody wonders where inadvertent reverting changes\ncome from, two most likely reasons are incorrect push into the\ncurrent branch's tip initiated from elsewhere, or incorrect\nfetch into the current branch's tip initiated from the\nrepository.\n\nIf your work repository is foo, and if you are working on\n'master' branch, you could\n\n\t$ cd ../bar ; git push ../foo master:master\n\nto push from elsewhere to update the tip of the checked out\nbranch.  This makes the index and the work tree that was based\non the old commit in foo repository totally out of sync with\nrespect to the HEAD (which you are replacing), and committing\nthat state would revert the change the above push made.\n\nYou can do the same by doing something equally silly and\ndestructive by:\n\n\t$ git fetch --update-head-ok ../bar master:master\n\nAfter these operations that could make your index and work\ntree state to include reverts, if you \"stash\", the stash will\nrecord that the reverting was what you wanted to do.\n\nI am not saying this is the only possible explanation though.\nYou can try:\n\n\tgit ls-tree stash@{1}\n        git rev-parse stash@{1}^1\n        git diff stash@{1}^1 stash@{1}^2\n\nThe stash entry itself is the state of the work tree, its first\nparent (i.e. ^1) is the commit your stash was originally based\non, and its second parent (i.e. ^2) is what was recorded in the\nindex.  Is the output from the first one empty?  Does the second\ncommand show you that you were on the commit you thought you were\non?  Does the third command show you what you thought you have\ntold \"git add\" to put in the index just before you made the\nstash?\n"},{"id":"53972","messageId":"DCBF8566-9B43-4EFA-A8B2-2EAB516C273F@steelskies.com","threadId":"9996","inReplyTo":"7vabrb8rin.fsf@gitster.siamese.dyndns.org","subject":"Re: My stash wants to delete all my files","fromName":"Jonathan del Strother","fromEmail":"maillist@steelskies.com","sentAt":"2007-09-25T09:27:06Z","receivedAt":"2007-09-25T09:27:06Z","isPatch":false,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"\nOn 25 Sep 2007, at 02:26, Junio C Hamano wrote:\n\n> Jonathan del Strother <maillist@steelskies.com> writes:\n>\n>> $ git stash list\n>> stash@{0}: On master: --apply\n>> stash@{1}: WIP on master: 09e3c30... Better handling of cell sizes in\n>> the grid\n>>\n>> $ git stash show stash@{1}\n>> ...\n>> 19 files changed, 0 insertions(+), 3805 deletions(-)\n>>\n>> Hmm.  Looks like it's trying to delete all of my versioned files.\n>> \"git stash apply stash@{1}\" confirms this.   Obviously that's not  \n>> what\n>> I tried to stash - my WIP when I stashed was a few additions, a  \n>> couple\n>> of new unversioned files, and moving a few lines of code from one  \n>> file\n>> to another.\n>>\n>> Any ideas what happened there?  I can't seem to reproduce the problem\n>> in a test repository.\n>\n> ...\n> Whenever anybody wonders where inadvertent reverting changes\n> come from, two most likely reasons are incorrect push into the\n> current branch's tip initiated from elsewhere, or incorrect\n> fetch into the current branch's tip initiated from the\n> repository.\n\nI'm working on a single isolated repository, so haven't pushed,  \npulled, fetched, or anything.\n\n\n> \tgit ls-tree stash@{1}\n>        git rev-parse stash@{1}^1\n>        git diff stash@{1}^1 stash@{1}^2\n>\n\nls-tree is empty.  rev-parse confirms I was on the right revision when  \nI stashed, and the diff shows everything being deleted.\n\n\n> Does the third command show you what you thought you have\n> told \"git add\" to put in the index just before you made the\n> stash?\n\nI don't think I git-added anything - just made changes to the working  \ncopy.  (It *does* stash those, right??)\n\n\nI'm at a loss to explain what happened here...\n"},{"id":"53975","messageId":"Pine.LNX.4.64.0709251054440.28395@racer.site","threadId":"9996","inReplyTo":"DCBF8566-9B43-4EFA-A8B2-2EAB516C273F@steelskies.com","subject":"Re: My stash wants to delete all my files","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-25T09:56:07Z","receivedAt":"2007-09-25T09:56:07Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 25 Sep 2007, Jonathan del Strother wrote:\n\n> I don't think I git-added anything - just made changes to the working \n> copy. (It *does* stash those, right??)\n\nStash does not care about things that are not tracked, so no, it does not \nstash those.  Imagine a stash saving all those .o, .a and .so files... \nInsanity!\n\nCiao,\nDscho\n"},{"id":"53977","messageId":"0F9BDBCD-06AA-4AB1-9DDA-9C98E8796AA1@steelskies.com","threadId":"9996","inReplyTo":"Pine.LNX.4.64.0709251054440.28395@racer.site","subject":"Re: My stash wants to delete all my files","fromName":"Jonathan del Strother","fromEmail":"maillist@steelskies.com","sentAt":"2007-09-25T10:22:55Z","receivedAt":"2007-09-25T10:22:55Z","isPatch":false,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"\nOn 25 Sep 2007, at 10:56, Johannes Schindelin wrote:\n\n> Hi,\n>\n> On Tue, 25 Sep 2007, Jonathan del Strother wrote:\n>\n>> I don't think I git-added anything - just made changes to the working\n>> copy. (It *does* stash those, right??)\n>\n> Stash does not care about things that are not tracked, so no, it  \n> does not\n> stash those.  Imagine a stash saving all those .o, .a and .so files...\n> Insanity!\n\n\nMm, ok - fair point.  I was actually thinking of files that are  \nalready tracked, but haven't been added to the staging area with git  \nadd.\n"},{"id":"53982","messageId":"Pine.LNX.4.64.0709251139480.28395@racer.site","threadId":"9996","inReplyTo":"0F9BDBCD-06AA-4AB1-9DDA-9C98E8796AA1@steelskies.com","subject":"Re: My stash wants to delete all my files","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-25T10:41:50Z","receivedAt":"2007-09-25T10:41:50Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 25 Sep 2007, Jonathan del Strother wrote:\n\n> On 25 Sep 2007, at 10:56, Johannes Schindelin wrote:\n> \n> > On Tue, 25 Sep 2007, Jonathan del Strother wrote:\n> > \n> > > I don't think I git-added anything - just made changes to the \n> > > working copy. (It *does* stash those, right??)\n> > \n> > Stash does not care about things that are not tracked, so no, it does \n> > not stash those.  Imagine a stash saving all those .o, .a and .so \n> > files... Insanity!\n> \n> \n> Mm, ok - fair point.  I was actually thinking of files that are already \n> tracked, but haven't been added to the staging area with git add.\n\nAh.  I read your statement as \"I don't think I git-added anything, ever\".\n\nSo this is what stash is supposed to do:\n\n- save the differences between the HEAD and the index\n\n- save the differences between the HEAD and the working tree\n\n- reset the index and the working tree to the state of the HEAD\n\nSo indeed, I am as puzzled as you are.  Maybe it was your initial commit?\n\nCiao,\nDscho\n"}]}