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

Requesting `git stash --cached` or something similar

From
QTQuinn Taylor <quinntaylor@mac.com>
Date
Apr 13, 2015, 21:24 UTC
Message-ID
<37E34942-ACEB-48BC-ABFF-C7248DA6607E@mac.com>
I'm still fairly new to git (coming from svn) and have found `git stash` to be really useful for storing in-progress work to resume later, as one might otherwise do with diff/patch files. (With the git tools I use, I find `git stash pop` to be more convenient and reliable than creating and applying diffs, partially because the changes remained tied to my repository and easily accessible.)
Since `git stash` defaults to stashing ALL local modifications, I'd like to request there be an easy way to stash *only* the changes I've already staged in the index. (The reason I suggested --cached is due to the similarity with `git diff --cached`, but I don't doubt there would be a better name for this option.)
I tried staging everything *except* what I want to stash and using `git stash save --keep-index <message>`, but it isn't intended to support this case, and doesn't work when I have new untracked files. Instead, it stashes *all* local (tracked) changes — both staged and unstaged — but leaves the staged changes intact in the index.
I understand that git's branching model is powerful and flexible, and that an experienced git user would generally create a private branch and commit to that, then merge the changes to mainline sometime later. However, for those like me for whom having many branches is generally more confusing than helpful, it would be fantastic to have more flexibility with `git stash`.
Thanks in advance for considering my request.
Regards,
 - Quinn
Next: Brandon McCaig
Message 1 of 5 in “Requesting `git stash --cached` or something similar”
  1. Quinn TaylorApr 13, 2015
  2. Brandon McCaigApr 14, 2015
  3. Trevor SaundersApr 14, 2015
  4. Brandon McCaigApr 14, 2015
  5. Trevor SaundersApr 14, 2015

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.