git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git-stash: RFC: Adopt the default behavior to other commands

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 19, 2007, 12:01 UTC
Message-ID
<Pine.LNX.4.64.0712191150240.23902@racer.site>
In-Reply-To
<46a038f90712182346t5309448egebfd3726f4d493c5@mail.gmail.com>
Hi,
On Wed, 19 Dec 2007, Martin Langhoff wrote:
Show 16 quoted lines
> On Dec 19, 2007 8:33 PM, Wincent Colaiuta <win@wincent.com> wrote:
> > El 19/12/2007, a las 0:41, Martin Langhoff escribi?:
> >
> > > On Dec 19, 2007 4:42 AM, J?rg Sommer <joerg@alea.gnuu.de> wrote:
> > >> I vote for stash print the list, because I dropped in the pitfall.
> > >
> > > I've dropped there myself, and work with a large team where we are 
> > > both fans of stash, and scarred by it. Any newcomer to git that 
> > > "discovers" stash gets hit by it a dozen times, this is completely 
> > > unnecesary.
> >
> > I may be missing something here, but what's the danger here? An
> 
> Surprise. Your working directory has *just* changed under your feet. 
> Maybe you have an editor with further unsaved changes that is about to 
> act confused whether you undo the stash or not.

The funny thing: why do you call stash with unsaved changes anyway? I mean, come on, even if you were planning to see the usage of stash (which you would get with -h), you undoubtedly wanted to either stash or unstash some changes. Otherwise you would not _need_ to see the usage to begin with.

Show 5 quoted lines
> > unexpected stash is incredibly easy to revert, unless I'm missing
> 
> Once you know about it, yes it is. Once you know about the reflog, you
> can sing and dance and never be worried. But for starting users, it's
> a dangerous command.
No.
Reflogs have nothing to do with it.

If you want to stash changes, you _got_ to know how to unstash those changes. Otherwise "git reset --hard" would have been your friend.

And so, I cannot help but believe that all users of stash -- even the new ones -- know about the fundamental concept of stashing/unstashing, and therefore it is more something like this:

	$ git stash
	[no usage?  What the heck... Oh, it stashed the changes.  I did 
	 not want to stash them just yet.  Okay:]
	$ git unstash
	No such command
	[Oh, maybe I should have read the man page.  Oh, well, the usage 
	 should do...]
	$ git stash -h
	...

Yes, if you start "git stash" blindly, believing that it does what "git stash -h" does, you will be bitten by it once.

But as I said, you will be bitten by a plenty commands if you are not familiar with the concept that "-h" shows the synopsis, "--help" the man page, and that there is a default action where possible.

But stash really is about things like
	$ git stash
	$ git pull
	$ git stash apply

I do not _want_ to see the stash list in _most_ cases, because I do not stash away million dirty changes.

And that workflow was what "git stash" was designed for.
Show 10 quoted lines
> > And nobody commented on the idea I posted earlier which seems to 
> > address the concerns about newbies not knowing what "git stash" with 
> > no params does:
> 
> I agree with making stash more verbose -- if the unlucky new user is
> paying close attention, they'll have instructions on to how to get out
> of trouble. But I agree more with making it "just verbose, no action"
> by default. There are two strong hints:
> 
>  - all other state-changing commands take parameters

What about "git commit", "git reset", "git fetch"? These definitely change state of the repository.

>  - quite a few people in this list have gotten burned with it

Okay, let's have a little calculation: IIRC 3 people (let's make it 10, to be conservative) have said that they had this problem. I must assume that all other people did not have the problem, or at least saw why the default action of "git stash" is what it is.

That said, if you _have_ to have the default changed, then I'll probably implement a "git push" and "git pop" alias here, so that I cannot get annoyed by stash's "new and improved" behaviour.

Ciao, Dscho

Previous: Andreas EricssonNext: Wincent Colaiuta
Message 32 of 33 in “git-stash: RFC: Adopt the default behavior to other commands”
  1. Sebastian HarlDec 17, 2007
  2. Benoit SigoureDec 17, 2007
  3. Junio C HamanoDec 17, 2007
  4. Benoit SigoureDec 17, 2007
  5. Junio C HamanoDec 18, 2007
  6. Sebastian HarlDec 18, 2007
  7. Johannes SchindelinDec 18, 2007
  8. Andreas EricssonDec 18, 2007
  9. Johannes SchindelinDec 18, 2007
  10. Andreas EricssonDec 18, 2007
  11. Johannes SchindelinDec 18, 2007
  12. Andreas EricssonDec 18, 2007
  13. Jakub NarebskiDec 18, 2007
  14. Andreas EricssonDec 18, 2007
  15. Johannes SchindelinDec 18, 2007
  16. Sergei OrganovDec 18, 2007
  17. Johannes SchindelinDec 18, 2007
  18. Martin LanghoffDec 18, 2007
  19. Wincent ColaiutaDec 18, 2007
  20. Jörg SommerDec 18, 2007
  21. Johannes SchindelinDec 18, 2007
  22. Junio C HamanoDec 18, 2007
  23. しらいしななこDec 20, 2007
  24. Junio C HamanoDec 20, 2007
  25. Wincent ColaiutaDec 21, 2007
  26. しらいしななこDec 21, 2007
  27. André Goddard RosaDec 18, 2007
  28. Martin LanghoffDec 18, 2007
  29. Wincent ColaiutaDec 19, 2007
  30. Martin LanghoffDec 19, 2007
  31. Andreas EricssonDec 19, 2007
  32. Johannes SchindelinDec 19, 2007
  33. Wincent ColaiutaDec 19, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.