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

Re: Stashing just index..working-copy rather than HEAD..working-copy?

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 24, 2024, 23:31 UTC
Message-ID
<xmqq1q6uwd5y.fsf@gitster.g>
In-Reply-To
<CAPx1GvcxyDDQmCssMjEnt6JoV6qPc5ZUpgPLX3mpUC_4PNYA1w@mail.gmail.com>
Chris Torek <chris.torek@gmail.com> writes:
> With all that said, I'd like to make one last suggestion, which
> I think is a lot simpler: *stop using `git stash`*.  Just make
> a commit!
;-)

If I recall correctly, the original design of "git stash" was "I save everything in the working tree, so that I can start working on an urgent request immediately, and then later restore everything", and there was no "--index" option for application, even though the stash entries were the W commit that is a merge of the I (index) commit and the B (base) commit. The "apply/pop --index" was a mere afterthought that does not work very well and made things more confusing. It wasn't meant to be used in anything complex, for which a separate branch with real commits were the way to go.

There were some reasons (like, working tree side post-commit hooks that are not well written to distinguish temporary commits from real ones and send out notifications outside) that some folks wanted to avoid making a commit on a temporary branch and to them, having a bit more complex "stash" may have been a way for them to avoid triggering those poorly designed workflow around post-commit hooks. But with modern Git in this age with workflows and disciplines better understood, I agree that we should encourage use of more temporary branches with real commits. If there are reasons to cause developers fear of commitment (e.g., "my $CORP environment forces me to show every commit I make to CI server, which slows me down and wastes resources if I make many tentative commits only for snapshot"), they should be solved in a way that users do not have to fear commitments.

Thanks.
Previous: Chris TorekNext: Tim Chase
Message 3 of 4 in “Stashing just index..working-copy rather than HEAD..working-copy?”
  1. Tim ChaseApr 24, 2024
  2. Chris TorekApr 24, 2024
  3. Junio C HamanoApr 24, 2024
  4. Tim ChaseApr 27, 2024

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.