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

Re: Proposal for git stash : add --staged option

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Apr 22, 2015, 09:25 UTC
Message-ID
<0082a449b4d1723cb557ac353a04c3af@www.dscho.org>
In-Reply-To
<96c00a316c79d9e5a85e199ba7d6f317@netapsys.fr>
Hi Edgar,
On 2015-04-22 10:30, edgar.hipp@netapsys.fr wrote:
Show 32 quoted lines
> When you have a lot of unstaged files, and would like to test what
> happens if you undo some of the changes that you think are unecessary,
> you would rather keep a copy of those changes somewhere.
> 
> For example
> 
> Changed but not updated:
>     M config_test.xml
>     M config_real.xml
> 
> I have changed both config_test.xml and config_real.xml, but I think
> the changes made in config_test.xml are unnecessary. However, I would
> still like to keep them somewhere in case it breaks something.
> 
> In this case for example, I would like to be able to stash only the
> file config_test.xml
> 
> Eg:
> 
> git add config_test.xml
> git stash --staged
> 
> So that after this, my git looks like this:
> 
> Changed but not updated:
>     M config_real.xml
> 
> and my stash contains only the changes introduced in config_test.xml
> 
> `git stash --keep-index` doesn't give the necessary control, because
> it will still stash everything (and create unnecessary merge
> complications if I change the files and apply the stash)
I often have the same problem. How about doing this:

```sh git add config_real.xml git stash -k git reset ```

The difference between our approaches is that I keep thinking of the staging area as the place to put changes I want to *keep*, not that I want to forget for a moment.
Having said that, I am sympathetic to your cause, although I would rather have `git stash [--patch] -- [<file>...]` that would be used like `git add -p` except that the selected changes are *not* staged, but stashed instead.

Ciao, Johannes

Previous: edgar.hipp@netapsys.frNext: edgar.hipp@netapsys.fr
Message 2 of 4 in “Proposal for git stash : add --staged option”
  1. edgar.hipp@netapsys.frApr 22, 2015
  2. Johannes SchindelinApr 22, 2015
  3. edgar.hipp@netapsys.frApr 23, 2015
  4. edgar.hipp@netapsys.frJun 3, 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.