{"thread":{"id":"24239","subject":"Implicit stashes","startedAt":"2010-06-30T02:48:38Z","lastAt":"2010-06-30T16:12:17Z","messageCount":8,"participants":["John Tapsell","Joshua Jensen","Jonathan Nieder","Sverre Rabbelier","Will Palmer","Alex"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"144497","messageId":"AANLkTilTaQP6qARY1A495vm9HAvLVX_lqIQd1l3WIv7a@mail.gmail.com","threadId":"24239","inReplyTo":null,"subject":"Implicit stashes","fromName":"John Tapsell","fromEmail":"johnflux@gmail.com","sentAt":"2010-06-30T02:48:38Z","receivedAt":"2010-06-30T02:48:38Z","isPatch":false,"sender":{"key":"johnflux@gmail.com","avatar":"https://gravatar.com/avatar/25f70d4c0f96396b84a2e34bcd9bdc233462c7b4be29b5fdca8266fc53f30b0c?d=mp&s=160"},"body":"Hi,\n\n  I was thinking that it would be nice if everything was undoable in\ngit.  Currently there are some easily typed by irreversible commands\nthat I keep seeing people doing.\n\nFor example:\n\n$ git checkout folder\n\nNow all changes that you just worked on are deleted, with no way of recovering.\n\n$ git reset --hard\n\nI know this seems very explicit to delete changes, but I myself have\ndone this and accidentally lost changes.  For example, I write a unit\ntest and don't commit it in on purpose because I know that it\ncurrently fails and I want to test it against older versions.  I\ncarefully git checkout older versions to find if the unit test fails,\nthen in stupidity reset back to origin/master ..\n\n\n  Anyway, I think a nice solution is to have a separate stash for\nimplicit stashes.  Then irreversible commands would simply stash\nbefore making the changes.\n  It would also be nice to add a 'git undo' which just undoes whatever\nthe last operation was - i.e  unstash or reset to an earlier HEAD@{1}\n\nJohn\n"},{"id":"144498","messageId":"4C2AB260.8020108@workspacewhiz.com","threadId":"24239","inReplyTo":"AANLkTilTaQP6qARY1A495vm9HAvLVX_lqIQd1l3WIv7a@mail.gmail.com","subject":"Re: Implicit stashes","fromName":"Joshua Jensen","fromEmail":"jjensen@workspacewhiz.com","sentAt":"2010-06-30T02:56:32Z","receivedAt":"2010-06-30T02:56:32Z","isPatch":false,"sender":{"key":"jjensen@workspacewhiz.com","avatar":"https://avatars.githubusercontent.com/u/111687?v=4"},"body":"  ----- Original Message -----\nFrom: John Tapsell\nDate: 6/29/2010 8:48 PM\n>    I was thinking that it would be nice if everything was undoable in\n> git.  Currently there are some easily typed by irreversible commands\n> that I keep seeing people doing.\n>\n> For example:\n>\n> $ git checkout folder\n>\n> Now all changes that you just worked on are deleted, with no way of recovering.\n>\n> $ git reset --hard\n>\n> I know this seems very explicit to delete changes, but I myself have\n> done this and accidentally lost changes.  For example, I write a unit\n> test and don't commit it in on purpose because I know that it\n> currently fails and I want to test it against older versions.  I\n> carefully git checkout older versions to find if the unit test fails,\n> then in stupidity reset back to origin/master ..\n>    Anyway, I think a nice solution is to have a separate stash for\n> implicit stashes.  Then irreversible commands would simply stash\n> before making the changes.\n>    It would also be nice to add a 'git undo' which just undoes whatever\n> the last operation was - i.e  unstash or reset to an earlier HEAD@{1}\nSee this thread: http://kerneltrap.org/mailarchive/git/2009/5/20/2915\n\nJosh\n"},{"id":"144499","messageId":"AANLkTimOTBzN7lnniImy2eqoBh775X9NbzIwcetS1GHh@mail.gmail.com","threadId":"24239","inReplyTo":"4C2AB260.8020108@workspacewhiz.com","subject":"Re: Implicit stashes","fromName":"John Tapsell","fromEmail":"johnflux@gmail.com","sentAt":"2010-06-30T03:05:50Z","receivedAt":"2010-06-30T03:05:50Z","isPatch":false,"sender":{"key":"johnflux@gmail.com","avatar":"https://gravatar.com/avatar/25f70d4c0f96396b84a2e34bcd9bdc233462c7b4be29b5fdca8266fc53f30b0c?d=mp&s=160"},"body":"On 30 June 2010 11:56, Joshua Jensen <jjensen@workspacewhiz.com> wrote:\n>  ----- Original Message -----\n> From: John Tapsell\n> Date: 6/29/2010 8:48 PM\n>>\n>>   I was thinking that it would be nice if everything was undoable in\n>> git.  Currently there are some easily typed by irreversible commands\n>> that I keep seeing people doing.\n>> <snip>\n> See this thread: http://kerneltrap.org/mailarchive/git/2009/5/20/2915\n\nDoh.\n\nIt seems that everyone agreed in principle, but that the details are\ntricky and it needs someone to actually do it.\n\nI can't do it myself, but I'll give $50 to someone to get this going\nand do this :)  (I know that is an insultingly low amount, sorry)\n\nJohn\n"},{"id":"144500","messageId":"20100630051326.GA17497@burratino","threadId":"24239","inReplyTo":"AANLkTilTaQP6qARY1A495vm9HAvLVX_lqIQd1l3WIv7a@mail.gmail.com","subject":"Dangers of reset --hard (Re: Implicit stashes)","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-30T05:13:26Z","receivedAt":"2010-06-30T05:13:26Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"John Tapsell wrote:\n\n> $ git reset --hard\n>\n> I know this seems very explicit to delete changes, but I myself have\n> done this and accidentally lost changes.  For example, I write a unit\n> test and don't commit it in on purpose because I know that it\n> currently fails and I want to test it against older versions.  I\n> carefully git checkout older versions to find if the unit test fails,\n> then in stupidity reset back to origin/master ..\n\nAside: I assume you already know about it, but still I cannot help but\ntake the opportunity to advertise ‘git reset --keep’.  I was added\nfairly recently (1.7.1 rc0) and I find myself annoyed when on machines\nwithout it because of almost exactly this use case.\n\nStephan and Christian: thanks for writing it.\n"},{"id":"144502","messageId":"AANLkTimIJcOe3fufZx83LxI8ZSDP8cCOj1BEPPbUy7Ol@mail.gmail.com","threadId":"24239","inReplyTo":"AANLkTimOTBzN7lnniImy2eqoBh775X9NbzIwcetS1GHh@mail.gmail.com","subject":"Re: Implicit stashes","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-06-30T05:57:03Z","receivedAt":"2010-06-30T05:57:03Z","isPatch":false,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Wed, Jun 30, 2010 at 05:05, John Tapsell <johnflux@gmail.com> wrote:\n> I can't do it myself, but I'll give $50 to someone to get this going\n> and do this :)  (I know that is an insultingly low amount, sorry)\n\nHehe, I'll match your $50 and raise you a beer ;). Isn't there some\nrelevant site where people can pledge for stuff like this? Either way,\nI doubt for most lack of financial stimulation is what's stopping them\nfrom implementing this, but rather lack of time which cannot really be\ncompensated financially.\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"144507","messageId":"1277885972.2498.25.camel@wpalmer.simply-domain","threadId":"24239","inReplyTo":"20100630051326.GA17497@burratino","subject":"Re: Dangers of reset --hard (Re: Implicit stashes)","fromName":"Will Palmer","fromEmail":"wmpalmer@gmail.com","sentAt":"2010-06-30T08:19:32Z","receivedAt":"2010-06-30T08:19:32Z","isPatch":false,"sender":{"key":"wmpalmer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/357044?v=4"},"body":"On Wed, 2010-06-30 at 00:13 -0500, Jonathan Nieder wrote:\n> John Tapsell wrote:\n> \n> > $ git reset --hard\n> >\n> > I know this seems very explicit to delete changes, but I myself have\n> > done this and accidentally lost changes.  For example, I write a unit\n> > test and don't commit it in on purpose because I know that it\n> > currently fails and I want to test it against older versions.  I\n> > carefully git checkout older versions to find if the unit test fails,\n> > then in stupidity reset back to origin/master ..\n> \n> Aside: I assume you already know about it, but still I cannot help but\n> take the opportunity to advertise ‘git reset --keep’.  I was added\n> fairly recently (1.7.1 rc0) and I find myself annoyed when on machines\n> without it because of almost exactly this use case.\n\nI tend to want \"do a git reset --hard, but fail if anything would be\nlost\". The use-case here is that when I reset --hard, I want a\ncompletely clean copy- but I don't want to accidentally lose anything.\n\nThis can probably be achieved with something like:\ngit diff-files --quiet &&\n  git diff-index --quiet HEAD &&\n  git diff-index --cached --quiet HEAD ||\n  git reset --hard \"$@\"\n\nI've got a half-done patch sitting at home which adds -g, --gentle to\n\"git reset\", which is intended to do exactly that- but my git-fu is not\nvery strong on the C end of things, so for the foreseeable future it\nwill remain an idea without a working implementation.\n"},{"id":"144511","messageId":"loom.20100630T132533-495@post.gmane.org","threadId":"24239","inReplyTo":"AANLkTimIJcOe3fufZx83LxI8ZSDP8cCOj1BEPPbUy7Ol@mail.gmail.com","subject":"Re: Implicit stashes","fromName":"Alex","fromEmail":"ajb44.geo@yahoo.com","sentAt":"2010-06-30T11:27:30Z","receivedAt":"2010-06-30T11:27:30Z","isPatch":false,"sender":{"key":"ajb44.geo@yahoo.com","avatar":null},"body":"Sverre Rabbelier <srabbelier <at> gmail.com> writes:\n\n\n> Hehe, I'll match your $50 and raise you a beer ;). Isn't there some\n> relevant site where people can pledge for stuff like this? Either way,\n> I doubt for most lack of financial stimulation is what's stopping them\n> from implementing this, but rather lack of time which cannot really be\n> compensated financially.\n\nThere are a few:\nhttp://fossfactory.org\nhttp://nextsprocket.com\nhttp://www.opensourcexperts.com/\n\nAlex\n"},{"id":"144535","messageId":"20100630161217.GE18813@burratino","threadId":"24239","inReplyTo":"1277885972.2498.25.camel@wpalmer.simply-domain","subject":"Re: Dangers of reset --hard (Re: Implicit stashes)","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-30T16:12:17Z","receivedAt":"2010-06-30T16:12:17Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Will Palmer wrote:\n\n> I tend to want \"do a git reset --hard, but fail if anything would be\n> lost\".\n\nAt the risk of being redundant: try git reset --keep.  If it succeeds,\nyou can use git diff --cached HEAD and git diff to check how close it\nwas to being equivalent to a hard reset.\n\n> The use-case here is that when I reset --hard, I want a\n> completely clean copy- but I don't want to accidentally lose anything.\n\nThere is one case when I truly want a completely clean copy (including\nno untracked files): when I am testing and a bit paranoid.  For that,\nI do something like the following:\n\n ; mkdir /tmp/test-dir\n ; git archive HEAD | (cd /tmp/test-dir && tar -xf -)\n ; cd /tmp/test-dir\n\nand work from there.  I would not be surprised if the needs of your\ncase are different, though.\n"}]}