{"thread":{"id":"10079","subject":"Stashing untracked files","startedAt":"2007-09-29T18:27:48Z","lastAt":"2007-09-30T21:25:56Z","messageCount":13,"participants":["Neil Macneale","Johannes Schindelin","Benoit SIGOURE","Tom Prince","Steffen Prohaska","Wincent Colaiuta","Tom Tobin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"54355","messageId":"46FE9924.7080006@theory.org","threadId":"10079","inReplyTo":null,"subject":"Stashing untracked files","fromName":"Neil Macneale","fromEmail":"mac4-git@theory.org","sentAt":"2007-09-29T18:27:48Z","receivedAt":"2007-09-29T18:27:48Z","isPatch":false,"sender":{"key":"mac4-git@theory.org","avatar":null},"body":"Hi All,\n\nI'm new to git, and I have a question regarding the best way to do \nsomething.\n\nWhen using \"git stash,\" in some cases I'd like to stash away files that \nare currently untracked. It seems to me like there should be a way to \nstash everything in a working directory so that the end result is a \npristine tree. Then applying the stash will reinstate those file as \nuntracked.\n\nI understand that is not always desired, but sometimes it is (for me \nanyway). Perhaps an option like \"git stash -u\" could provide this behavior?\n\nIs there some other approach that makes more sense? I don't want to \nstart looking into this until I have some idea if this is a sane idea :-)\n\nThanks,\nNeil\n"},{"id":"54360","messageId":"Pine.LNX.4.64.0709292201400.28395@racer.site","threadId":"10079","inReplyTo":"46FE9924.7080006@theory.org","subject":"Re: Stashing untracked files","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-29T21:03:22Z","receivedAt":"2007-09-29T21:03:22Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 29 Sep 2007, Neil Macneale wrote:\n\n> When using \"git stash,\" in some cases I'd like to stash away files that \n> are currently untracked. It seems to me like there should be a way to \n> stash everything in a working directory so that the end result is a \n> pristine tree. Then applying the stash will reinstate those file as \n> untracked.\n\nFunny how the same ideas always come in packs: I had the same discussions \na few nights ago on IRC.\n\nHere is why I think it is _wrong_ to stash untracked files: this would \ninclude *.o and *.a, as well as all those binary files, too.\n\nInstead this is what you _should_ do:\n\ngit add <the files that you care about>\ngit stash\n\nHth,\nDscho\n"},{"id":"54361","messageId":"EEE8F630-AE62-4425-96A0-239D54724DF4@lrde.epita.fr","threadId":"10079","inReplyTo":"Pine.LNX.4.64.0709292201400.28395@racer.site","subject":"Re: Stashing untracked files","fromName":"Benoit SIGOURE","fromEmail":"tsuna@lrde.epita.fr","sentAt":"2007-09-29T21:10:49Z","receivedAt":"2007-09-29T21:10:49Z","isPatch":false,"sender":{"key":"tsunanet@gmail.com","avatar":"https://avatars.githubusercontent.com/u/128281?v=4"},"body":"On Sep 29, 2007, at 11:03 PM, Johannes Schindelin wrote:\n\n> Hi,\n>\n> On Sat, 29 Sep 2007, Neil Macneale wrote:\n>\n>> When using \"git stash,\" in some cases I'd like to stash away files  \n>> that\n>> are currently untracked. It seems to me like there should be a way to\n>> stash everything in a working directory so that the end result is a\n>> pristine tree. Then applying the stash will reinstate those file as\n>> untracked.\n>\n> Funny how the same ideas always come in packs: I had the same  \n> discussions\n> a few nights ago on IRC.\n>\n> Here is why I think it is _wrong_ to stash untracked files: this would\n> include *.o and *.a, as well as all those binary files, too.\n>\n> Instead this is what you _should_ do:\n>\n> git add <the files that you care about>\n> git stash\n\nYou could stash untracked files that are not ignored (I personally  \nignore *.o, *.a and the like).\n\n-- \nBenoit Sigoure aka Tsuna\nEPITA Research and Development Laboratory\n\n\n"},{"id":"54364","messageId":"46FEC799.30803@theory.org","threadId":"10079","inReplyTo":"EEE8F630-AE62-4425-96A0-239D54724DF4@lrde.epita.fr","subject":"Re: Stashing untracked files","fromName":"Neil Macneale","fromEmail":"mac4-git@theory.org","sentAt":"2007-09-29T21:46:01Z","receivedAt":"2007-09-29T21:46:01Z","isPatch":false,"sender":{"key":"mac4-git@theory.org","avatar":null},"body":"Benoit SIGOURE wrote:\n> On Sep 29, 2007, at 11:03 PM, Johannes Schindelin wrote:\n> \n>> Hi,\n>>\n>> On Sat, 29 Sep 2007, Neil Macneale wrote:\n>>\n>>> When using \"git stash,\" in some cases I'd like to stash away files that\n>>> are currently untracked. It seems to me like there should be a way to\n>>> stash everything in a working directory so that the end result is a\n>>> pristine tree. Then applying the stash will reinstate those file as\n>>> untracked.\n>>\n>> Funny how the same ideas always come in packs: I had the same discussions\n>> a few nights ago on IRC.\n>>\n>> Here is why I think it is _wrong_ to stash untracked files: this would\n>> include *.o and *.a, as well as all those binary files, too.\n>>\n>> Instead this is what you _should_ do:\n>>\n>> git add <the files that you care about>\n>> git stash\n> \n> You could stash untracked files that are not ignored (I personally \n> ignore *.o, *.a and the like).\n> \nYeah, I wouldn't want the ignored files. I'm interested in the files \nlisted as untracked when I run git status.\n\nPerforming an add would require me to remove those file from the index \nat a later date in the event that I don't want to commit them on the \nnext commit.\n\nIn the case I'm dealing with right now, I working on content files \n(html/perl). It's not uncommon for me to have files which are untracked \nand will remain that way for an extended period of time (a few commits, \nsay). When I need to do a stash, I generally don't want those files \naround afterward.\n\n( Here is the full story. I'm using git to make my life working with \nperforce a little less painful. It's not uncommon for me to jump to my \nmaster branch to do a perforce sync. When I do that, I want all of my \nchanges in working branches stashed away. I selectively add new files on \neach commit so that what is committed to the working branch syncs up \nwith what I end up submitting to perforce. And to make my life even more \ndifficult, my co-workers are not using git. So it's not uncommon for \nsomeone to send me a file for my sandbox which I will never submit to \nperforce because it's their job to do so. I can't tell you how many \ntimes I've told them \"this would be a lot easier if we all just used \ngit\" but I digress... )\n\nThanks,\nNeil\n"},{"id":"54366","messageId":"Pine.LNX.4.64.0709292248400.28395@racer.site","threadId":"10079","inReplyTo":"EEE8F630-AE62-4425-96A0-239D54724DF4@lrde.epita.fr","subject":"Re: Stashing untracked files","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-29T21:51:32Z","receivedAt":"2007-09-29T21:51:32Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 29 Sep 2007, Benoit SIGOURE wrote:\n\n> On Sep 29, 2007, at 11:03 PM, Johannes Schindelin wrote:\n> \n> > Instead this is what you _should_ do:\n> > \n> > git add <the files that you care about>\n> > git stash\n> \n> You could stash untracked files that are not ignored (I personally \n> ignore *.o, *.a and the like).\n\nAnd what if you happen to forget to ignore that?  Or if you happen to \nhave an strace log in some file (which you did not ignore either)?\n\nThanks, but I think the semantics of git stash is pretty well defined.  \nAnd it means that you stash away _tracked_ content that was not yet \ncommitted.\n\nI mean, you can have your desired behaviour with\n\n$ git add .\n$ git stash\n\nbut if we were to fulfil your wish and change the default behaviour, there \nis no way back to the current behaviour (which I happen to find pretty \nsane).\n\nCiao,\nDscho\n"},{"id":"54367","messageId":"Pine.LNX.4.64.0709292259070.28395@racer.site","threadId":"10079","inReplyTo":"46FEC799.30803@theory.org","subject":"Re: Stashing untracked files","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-29T22:00:27Z","receivedAt":"2007-09-29T22:00:27Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\n[please do not cull me from the Cc: list, especially if you quote me.]\n\nOn Sat, 29 Sep 2007, Neil Macneale wrote:\n\n> Performing an add would require me to remove those file from the index \n> at a later date in the event that I don't want to commit them on the \n> next commit.\n\nWrong.\n\nIf you \"git add <new-file>\" and then \"git stash\", it will no longer have \nthe file in the index.  Instead, the index will agree with the HEAD (which \ndoes not have <new-file>).\n\nCiao,\nDscho\n"},{"id":"54372","messageId":"20070929222320.GB2947@hermes.priv","threadId":"10079","inReplyTo":"Pine.LNX.4.64.0709292248400.28395@racer.site","subject":"Re: Stashing untracked files","fromName":"Tom Prince","fromEmail":"tom.prince@ualberta.net","sentAt":"2007-09-29T22:23:21Z","receivedAt":"2007-09-29T22:23:21Z","isPatch":false,"sender":{"key":"tom.prince@ualberta.net","avatar":"https://gravatar.com/avatar/a0ad19caee7618876339485106ec994f5202505eecd210ba5c0bd869feaa555a?d=mp&s=160"},"body":"> > You could stash untracked files that are not ignored (I personally \n> > ignore *.o, *.a and the like).\n> \n> And what if you happen to forget to ignore that?  Or if you happen to \n> have an strace log in some file (which you did not ignore either)?\n> \n> Thanks, but I think the semantics of git stash is pretty well defined.  \n> And it means that you stash away _tracked_ content that was not yet \n> committed.\n> \n> I mean, you can have your desired behaviour with\n> \n> $ git add .\n> $ git stash\n> \n> but if we were to fulfil your wish and change the default behaviour, there \n> is no way back to the current behaviour (which I happen to find pretty \n> sane).\n\nBut\n\ngit add .\ngit stash\ngit stash apply\n\nwill not be a no-op any more.\n\nIt doesn't need to be a default, but there are certainly times when I would\nfind the option to stash untracked files convenient.\n\n  Tom\n"},{"id":"54377","messageId":"Pine.LNX.4.64.0709300007370.28395@racer.site","threadId":"10079","inReplyTo":"20070929222320.GB2947@hermes.priv","subject":"Re: Stashing untracked files","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-29T23:09:00Z","receivedAt":"2007-09-29T23:09:00Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 29 Sep 2007, Tom Prince wrote:\n\n> > > You could stash untracked files that are not ignored (I personally \n> > > ignore *.o, *.a and the like).\n> > \n> > And what if you happen to forget to ignore that?  Or if you happen to \n> > have an strace log in some file (which you did not ignore either)?\n> > \n> > Thanks, but I think the semantics of git stash is pretty well defined.  \n> > And it means that you stash away _tracked_ content that was not yet \n> > committed.\n> > \n> > I mean, you can have your desired behaviour with\n> > \n> > $ git add .\n> > $ git stash\n> > \n> > but if we were to fulfil your wish and change the default behaviour, \n> > there is no way back to the current behaviour (which I happen to find \n> > pretty sane).\n> \n> But\n> \n> git add .\n> git stash\n> git stash apply\n> \n> will not be a no-op any more.\n\nIt never was.  (Or did you mean \"git stash apply --index\"?)\n\n> It doesn't need to be a default, but there are certainly times when I \n> would find the option to stash untracked files convenient.\n\nBut then I'll have to ask you why the untracked files, which are not \ntouched by git, have to be stashed anyway?\n\nI'm seriously thinking that we are in deep \"XY problem\" land here.\n\nCiao,\nDscho\n"},{"id":"54390","messageId":"46FF1F1E.2050000@theory.org","threadId":"10079","inReplyTo":"Pine.LNX.4.64.0709292259070.28395@racer.site","subject":"Re: Stashing untracked files","fromName":"Neil Macneale","fromEmail":"mac4-git@theory.org","sentAt":"2007-09-30T03:59:26Z","receivedAt":"2007-09-30T03:59:26Z","isPatch":false,"sender":{"key":"mac4-git@theory.org","avatar":null},"body":"Johannes Schindelin wrote:\n> Hi,\n> \n> [please do not cull me from the Cc: list, especially if you quote me.]\n> \n> On Sat, 29 Sep 2007, Neil Macneale wrote:\n> \n>> Performing an add would require me to remove those file from the index \n>> at a later date in the event that I don't want to commit them on the \n>> next commit.\n> \n> Wrong.\n> \n> If you \"git add <new-file>\" and then \"git stash\", it will no longer have \n> the file in the index.  Instead, the index will agree with the HEAD (which \n> does not have <new-file>).\n> \n> Ciao,\n> Dscho\n\nTo be a little more clear, this is why I'd like to stash untracked files.\n\n$ <hack hack>    # source tree is a mess\n$ git stash -u   # stash everything, even untracked files. I never\n                  # suggesting modifying the default behavior.\n$ <fix bug>\n$ git commit -a\n$ git stash apply\n$ hack some more\n$ git add file1 file2  # I'm ready for some things to be committed,\n                        # but my source tree is still a mess.\n$ git commit\n\nTo do what you are suggesting would be something like this (correct me \nif I'm wrong):\n\n$ <hack hack>\n$ git add .      # Additional step, not a big deal.\n$ git stash\n$ <fix bug>\n$ git commit -a\n$ git stash apply\n$ git reset HEAD <all file I don't actually need to add but was forced\n                   to add in step above.>\n                  # What concerns me is that I may not reset some files\n                  # that need to be reset, or reset other ones which\n                  # should not be reset. This is the headache I want to\n                  # avoid.\n$ <hack hack>\n$ git add file1 file2\n$ git commit\n\ngit stash is an acknowledgment that not everything needs to be \ncommitted, and sometimes working source trees are messy. Prior to the \nstash command, I just accepted that I'd need to commit everything and do \n  some maintenance to un-commit those changes. stash is awesome for me \nand the realities of the way I need to work. IMHO, it would be the best \nthing since sliced bread if it handled untracked files.\n\nIf this is really just a problem for me, I can write a shell script to \ndo the dirty work. I just wonder if it is a common enough use case that \nit merits support in the tool itself.\n\nCheers,\nNeil\n"},{"id":"54400","messageId":"E505AC4A-FDCB-4D9D-9CF7-C68CBC20BFFD@zib.de","threadId":"10079","inReplyTo":"46FF1F1E.2050000@theory.org","subject":"Re: Stashing untracked files","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-09-30T08:41:47Z","receivedAt":"2007-09-30T08:41:47Z","isPatch":false,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Sep 30, 2007, at 5:59 AM, Neil Macneale wrote:\n\n> git stash is an acknowledgment that not everything needs to be  \n> committed, and sometimes working source trees are messy. Prior to  \n> the stash command, I just accepted that I'd need to commit  \n> everything and do  some maintenance to un-commit those changes.  \n> stash is awesome for me and the realities of the way I need to  \n> work. IMHO, it would be the best thing since sliced bread if it  \n> handled untracked files.\n\nI agree, it could be a great tool. Even only to make me feel better\nbefore running 'git clean' on a larger source tree when I was to\nlazy to scan 'git clean -n' in detail.\n\nBTW, I don't have results of the builds in my work tree but keep\nthem in a separate directory. Nearly everything in the work tree\nis 'real' source code, maybe cluttered with some backups or tmp files.\n\n\n> If this is really just a problem for me, I can write a shell script  \n> to do the dirty work. I just wonder if it is a common enough use  \n> case that it merits support in the tool itself.\n\nI think it would be useful. Here is a problem I ran into last week:\n\nA merge failed because it wanted to add a file not tracked by\nthe current branch. At first I didn't fully appreciate this fact\nand thought that 'git stash' could help. But to do so, it would\nneed to store the _untracked_ file and remove it from the work tree.\nThis would allow the merge to succeed. Current stash didn't really\nhelp.\n\n\tSteffen\n"},{"id":"54409","messageId":"115E3AB7-BE23-472B-9321-641901054A6A@wincent.com","threadId":"10079","inReplyTo":"46FF1F1E.2050000@theory.org","subject":"Re: Stashing untracked files","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-09-30T13:18:17Z","receivedAt":"2007-09-30T13:18:17Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 30/9/2007, a las 5:59, Neil Macneale escribió:\n\n> $ git stash -u   # stash everything, even untracked files. I never\n>                  # suggesting modifying the default behavior.\n\nProvided it's not the default behaviour, and provided that it doesn't  \nadd ignored files, this sounds perfectly reasonable and potentially  \nquite useful.\n\nI say *potentially* only because I've yet to find a situation wherein  \nI can't just do the following:\n\n<hack>                # lots of untracked files floating around\n$ git stash           # untracked files stay exactly where they were\n<orthogonal hacking>  # untracked files still there\n$ git stash apply     # still there...\n<hack>                # still there...\n\nIf the content of the untracked files is both, (a) important and (b)  \nbeing modified over time, then perhaps it should be being tracked.\n\nWincent\n"},{"id":"54431","messageId":"bf0b20a90709301344j1ac8f538u616fb4ba3fc47efe@mail.gmail.com","threadId":"10079","inReplyTo":"46FE9924.7080006@theory.org","subject":"Re: Stashing untracked files","fromName":"Tom Tobin","fromEmail":"korpios@korpios.com","sentAt":"2007-09-30T20:44:19Z","receivedAt":"2007-09-30T20:44:19Z","isPatch":false,"sender":{"key":"korpios@korpios.com","avatar":null},"body":"On 9/29/07, Neil Macneale <mac4-git@theory.org> wrote:\n> When using \"git stash,\" in some cases I'd like to stash away files that\n> are currently untracked. It seems to me like there should be a way to\n> stash everything in a working directory so that the end result is a\n> pristine tree. Then applying the stash will reinstate those file as\n> untracked.\n\nSince this is an itch of my own, I have a local copy of git-stash that\ndoes this (stashes away the untracked -- but not ignored -- files, and\nrestores them as untracked upon \"stash apply\"); unfortunately, I'm\npretty new to git, so I'm certain my code is *quite* unoptimized and\nugly.  As soon as I feel comfortable with it (which should include\nmaking the new behavior optional), I'll drop a line here with some\ncode.  :-)\n"},{"id":"54439","messageId":"Pine.LNX.4.64.0709302224270.28395@racer.site","threadId":"10079","inReplyTo":"bf0b20a90709301344j1ac8f538u616fb4ba3fc47efe@mail.gmail.com","subject":"Re: Stashing untracked files","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-30T21:25:56Z","receivedAt":"2007-09-30T21:25:56Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 30 Sep 2007, Tom Tobin wrote:\n\n> On 9/29/07, Neil Macneale <mac4-git@theory.org> wrote:\n> > When using \"git stash,\" in some cases I'd like to stash away files \n> > that are currently untracked. It seems to me like there should be a \n> > way to stash everything in a working directory so that the end result \n> > is a pristine tree. Then applying the stash will reinstate those file \n> > as untracked.\n> \n> Since this is an itch of my own, I have a local copy of git-stash that \n> does this (stashes away the untracked -- but not ignored -- files, and \n> restores them as untracked upon \"stash apply\"); unfortunately, I'm \n> pretty new to git, so I'm certain my code is *quite* unoptimized and \n> ugly.  As soon as I feel comfortable with it (which should include \n> making the new behavior optional), I'll drop a line here with some code.  \n> :-)\n\nWe are known on this list for never biting someone's head off, especially \nnot when posting patches.\n\nWhy not just post it, see what comments come back, adapt it, and repost?  \nMore often than not, people learn by getting their code reviewed, and \nfaster so when the code is reviewed early.\n\nCiao,\nDscho\n"}]}