{"thread":{"id":"39133","subject":"Proposal for git stash : add --staged option","startedAt":"2015-04-22T08:30:26Z","lastAt":"2015-06-03T13:32:30Z","messageCount":4,"participants":["edgar.hipp@netapsys.fr","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"259788","messageId":"96c00a316c79d9e5a85e199ba7d6f317@netapsys.fr","threadId":"39133","inReplyTo":null,"subject":"Proposal for git stash : add --staged option","fromName":"","fromEmail":"edgar.hipp@netapsys.fr","sentAt":"2015-04-22T08:30:26Z","receivedAt":"2015-04-22T08:30:26Z","isPatch":false,"sender":{"key":"edgar.hipp@netapsys.fr","avatar":"https://gravatar.com/avatar/75aaa5ce32f709d766ca3039964b45900f0ef14e100e80c8059b204b454dc96b?d=mp&s=160"},"body":"Hello,\n\nThere's some feature of git that I have been missing.\nWhen you have a lot of unstaged files, and would like to test what \nhappens if you undo some of the changes that you think are unecessary, \nyou would rather keep a copy of those changes somewhere.\n\nFor example\n\nChanged but not updated:\n     M config_test.xml\n     M config_real.xml\n\nI have changed both config_test.xml and config_real.xml, but I think the \nchanges made in config_test.xml are unnecessary. However, I would still \nlike to keep them somewhere in case it breaks something.\n\nIn this case for example, I would like to be able to stash only the file \nconfig_test.xml\n\nEg:\n\ngit add config_test.xml\ngit stash --staged\n\nSo that after this, my git looks like this:\n\nChanged but not updated:\n     M config_real.xml\n\nand my stash contains only the changes introduced in config_test.xml\n\n`git stash --keep-index` doesn't give the necessary control, because it \nwill still stash everything (and create unnecessary merge complications \nif I change the files and apply the stash)\n\nBest,\n\nEdgar\n"},{"id":"259790","messageId":"0082a449b4d1723cb557ac353a04c3af@www.dscho.org","threadId":"39133","inReplyTo":"96c00a316c79d9e5a85e199ba7d6f317@netapsys.fr","subject":"Re: Proposal for git stash : add --staged option","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-04-22T09:25:41Z","receivedAt":"2015-04-22T09:25:41Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Edgar,\n\nOn 2015-04-22 10:30, edgar.hipp@netapsys.fr wrote:\n\n> When you have a lot of unstaged files, and would like to test what\n> happens if you undo some of the changes that you think are unecessary,\n> you would rather keep a copy of those changes somewhere.\n> \n> For example\n> \n> Changed but not updated:\n>     M config_test.xml\n>     M config_real.xml\n> \n> I have changed both config_test.xml and config_real.xml, but I think\n> the changes made in config_test.xml are unnecessary. However, I would\n> still like to keep them somewhere in case it breaks something.\n> \n> In this case for example, I would like to be able to stash only the\n> file config_test.xml\n> \n> Eg:\n> \n> git add config_test.xml\n> git stash --staged\n> \n> So that after this, my git looks like this:\n> \n> Changed but not updated:\n>     M config_real.xml\n> \n> and my stash contains only the changes introduced in config_test.xml\n> \n> `git stash --keep-index` doesn't give the necessary control, because\n> it will still stash everything (and create unnecessary merge\n> complications if I change the files and apply the stash)\n\nI often have the same problem. How about doing this:\n\n```sh\ngit add config_real.xml\ngit stash -k\ngit reset\n```\n\nThe 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.\n\nHaving 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.\n\nCiao,\nJohannes\n"},{"id":"259886","messageId":"5e4970b583a71bb577b0f8b8b9b7828c@netapsys.fr","threadId":"39133","inReplyTo":"0082a449b4d1723cb557ac353a04c3af@www.dscho.org","subject":"Re: Proposal for git stash : add --staged option","fromName":"","fromEmail":"edgar.hipp@netapsys.fr","sentAt":"2015-04-23T06:59:08Z","receivedAt":"2015-04-23T06:59:08Z","isPatch":false,"sender":{"key":"edgar.hipp@netapsys.fr","avatar":"https://gravatar.com/avatar/75aaa5ce32f709d766ca3039964b45900f0ef14e100e80c8059b204b454dc96b?d=mp&s=160"},"body":"Hi,\n\n\nthe\n\n> ```sh\n> git add config_real.xml\n> git stash -k\n> git reset\n> ```\n\nis not very well suited because the -k option to keep the index. \nHowever, the index will still be put inside the stash.\n\nSo what you propose is equivalent to:\n\n```sh\ngit stash\ngit stash apply stash@\\{0\\}\ngit checkout --config_test.xml\n```\n\n`git stash --patch` can do the job (and I think that's what I'm going to \nuse from now), but it's still a bit cumbersome in some situations.\n\nBest,\n\nEdgar\n\nLe 2015-04-22 11:25, Johannes Schindelin a écrit :\n> Hi Edgar,\n> \n> On 2015-04-22 10:30, edgar.hipp@netapsys.fr wrote:\n> \n>> When you have a lot of unstaged files, and would like to test what\n>> happens if you undo some of the changes that you think are unecessary,\n>> you would rather keep a copy of those changes somewhere.\n>> \n>> For example\n>> \n>> Changed but not updated:\n>>     M config_test.xml\n>>     M config_real.xml\n>> \n>> I have changed both config_test.xml and config_real.xml, but I think\n>> the changes made in config_test.xml are unnecessary. However, I would\n>> still like to keep them somewhere in case it breaks something.\n>> \n>> In this case for example, I would like to be able to stash only the\n>> file config_test.xml\n>> \n>> Eg:\n>> \n>> git add config_test.xml\n>> git stash --staged\n>> \n>> So that after this, my git looks like this:\n>> \n>> Changed but not updated:\n>>     M config_real.xml\n>> \n>> and my stash contains only the changes introduced in config_test.xml\n>> \n>> `git stash --keep-index` doesn't give the necessary control, because\n>> it will still stash everything (and create unnecessary merge\n>> complications if I change the files and apply the stash)\n> \n> I often have the same problem. How about doing this:\n> \n> ```sh\n> git add config_real.xml\n> git stash -k\n> git reset\n> ```\n> \n> The difference between our approaches is that I keep thinking of the\n> staging area as the place to put changes I want to *keep*, not that I\n> want to forget for a moment.\n> \n> Having said that, I am sympathetic to your cause, although I would\n> rather have `git stash [--patch] -- [<file>...]` that would be used\n> like `git add -p` except that the selected changes are *not* staged,\n> but stashed instead.\n> \n> Ciao,\n> Johannes\n"},{"id":"262863","messageId":"3abd6c1640b01ee2c53ef423723480b1@netapsys.fr","threadId":"39133","inReplyTo":"0082a449b4d1723cb557ac353a04c3af@www.dscho.org","subject":"Re: Proposal for git stash : add --staged option","fromName":"","fromEmail":"edgar.hipp@netapsys.fr","sentAt":"2015-06-03T13:32:30Z","receivedAt":"2015-06-03T13:32:30Z","isPatch":false,"sender":{"key":"edgar.hipp@netapsys.fr","avatar":"https://gravatar.com/avatar/75aaa5ce32f709d766ca3039964b45900f0ef14e100e80c8059b204b454dc96b?d=mp&s=160"},"body":"Hi again,\n\njust wanted to tell that I have created a solution by doing a few lines \nof scripting:\n\ngit-cstash\n```\n#/bin/sh\n\ngit commit -m 'temporary, will be stashed soon'\ngit stash --include-untracked\ngit reset HEAD^1\ngit stash\ngit stash pop stash@{1}\n```\n\nLe 2015-04-22 11:25, Johannes Schindelin a écrit :\n> Hi Edgar,\n> \n> On 2015-04-22 10:30, edgar.hipp@netapsys.fr wrote:\n> \n>> When you have a lot of unstaged files, and would like to test what\n>> happens if you undo some of the changes that you think are unecessary,\n>> you would rather keep a copy of those changes somewhere.\n>> \n>> For example\n>> \n>> Changed but not updated:\n>>     M config_test.xml\n>>     M config_real.xml\n>> \n>> I have changed both config_test.xml and config_real.xml, but I think\n>> the changes made in config_test.xml are unnecessary. However, I would\n>> still like to keep them somewhere in case it breaks something.\n>> \n>> In this case for example, I would like to be able to stash only the\n>> file config_test.xml\n>> \n>> Eg:\n>> \n>> git add config_test.xml\n>> git stash --staged\n>> \n>> So that after this, my git looks like this:\n>> \n>> Changed but not updated:\n>>     M config_real.xml\n>> \n>> and my stash contains only the changes introduced in config_test.xml\n>> \n>> `git stash --keep-index` doesn't give the necessary control, because\n>> it will still stash everything (and create unnecessary merge\n>> complications if I change the files and apply the stash)\n> \n> I often have the same problem. How about doing this:\n> \n> ```sh\n> git add config_real.xml\n> git stash -k\n> git reset\n> ```\n> \n> The difference between our approaches is that I keep thinking of the\n> staging area as the place to put changes I want to *keep*, not that I\n> want to forget for a moment.\n> \n> Having said that, I am sympathetic to your cause, although I would\n> rather have `git stash [--patch] -- [<file>...]` that would be used\n> like `git add -p` except that the selected changes are *not* staged,\n> but stashed instead.\n> \n> Ciao,\n> Johannes\n"}]}