{"thread":{"id":"35364","subject":"defaulting git stash to \"--keep-index\"","startedAt":"2013-11-20T01:50:09Z","lastAt":"2013-11-20T02:10:25Z","messageCount":3,"participants":["Tim Chase","Nathan Collins","Jason St. John"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"230827","messageId":"20131119195009.6d4e183b@bigbox.christie.dr","threadId":"35364","inReplyTo":null,"subject":"defaulting git stash to \"--keep-index\"","fromName":"Tim Chase","fromEmail":"git@tim.thechases.com","sentAt":"2013-11-20T01:50:09Z","receivedAt":"2013-11-20T01:50:09Z","isPatch":false,"sender":{"key":"git@tim.thechases.com","avatar":null},"body":"Having lost \"add -p\" work enough times when stashing, I finally\ndug into the docs to see how to prevent it, discovering that\n\"--keep-index\" does exactly what I want.  However, now I have trouble\nremembering to add the \"--keep-index\" until after I've shot myself in\nthe foot.  How do I go about getting \"git stash\" to default to\n\"--keep-index\"?  I've played around a little with aliases, but\nhaven't found the right incantation.\n\nThe existence of \"--no-keep-index\" suggests there's some way to make\n\"--keep-index\" the default, but I'm missing it.\n\nThanks,\n\n-tkc\n"},{"id":"230828","messageId":"CAO8RVvdMD+xWrkwk+9Nbm7oyTTkc50PURxJe67ygkkTN-L41zw@mail.gmail.com","threadId":"35364","inReplyTo":"20131119195009.6d4e183b@bigbox.christie.dr","subject":"Re: defaulting git stash to \"--keep-index\"","fromName":"Nathan Collins","fromEmail":"nathan.collins@gmail.com","sentAt":"2013-11-20T02:08:33Z","receivedAt":"2013-11-20T02:08:33Z","isPatch":false,"sender":{"key":"nathan.collins@gmail.com","avatar":"https://gravatar.com/avatar/ecec917e18a103ea8fa2cddf99d766caa0f52d0aef155ba715a9ada837b5c1d2?d=mp&s=160"},"body":"On Tue, Nov 19, 2013 at 5:50 PM, Tim Chase <git@tim.thechases.com> wrote:\n> Having lost \"add -p\" work enough times when stashing, I finally\n> dug into the docs to see how to prevent it, discovering that\n> \"--keep-index\" does exactly what I want.\n\nNote that 'git stash (pop | apply) --index' will reinstate the index\nas it was at stash time, regardless of whether '--keep-index' was used\nto create the stash.  In other words, your index is not \"lost\" when\nyou stash.\n\nAlso note: when you 'git stash --keep-index', although your index\nremains intact, the changes in the your index still become part of the\nstash.  Hence, any changes to the indexed portion of your files after\na stash usually result in a conflict on subsequent 'git stash pop'.\nThis confuses me quite a lot, since I'd expect a main use case of 'git\nstash --keep-index' to be fixing a up a commit, but then any fixes\ncause a conflict :P\n\nCheers,\n\n-nathan\n"},{"id":"230829","messageId":"CAEjxke_FNoj__J0y6JoXiFTAYY7WGDP4ntwJXcJO8=gxASbQCQ@mail.gmail.com","threadId":"35364","inReplyTo":"20131119195009.6d4e183b@bigbox.christie.dr","subject":"Re: defaulting git stash to \"--keep-index\"","fromName":"Jason St. John","fromEmail":"jstjohn@purdue.edu","sentAt":"2013-11-20T02:10:25Z","receivedAt":"2013-11-20T02:10:25Z","isPatch":false,"sender":{"key":"jstjohn@purdue.edu","avatar":"https://avatars.githubusercontent.com/u/1393510?v=4"},"body":"On Tue, Nov 19, 2013 at 8:50 PM, Tim Chase <git@tim.thechases.com> wrote:\n> Having lost \"add -p\" work enough times when stashing, I finally\n> dug into the docs to see how to prevent it, discovering that\n> \"--keep-index\" does exactly what I want.  However, now I have trouble\n> remembering to add the \"--keep-index\" until after I've shot myself in\n> the foot.  How do I go about getting \"git stash\" to default to\n> \"--keep-index\"?  I've played around a little with aliases, but\n> haven't found the right incantation.\n>\n> The existence of \"--no-keep-index\" suggests there's some way to make\n> \"--keep-index\" the default, but I'm missing it.\n>\n> Thanks,\n>\n> -tkc\n>\n>\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\ngit-config(1) states that you cannot hide existing Git commands. In\nother words, aliasing \"git stash\" to \"git stash --keep-index\" is not\npossible. You could try playing around with the exclamation point\nversion (e.g. `git config \"alias.stash = !git stash --keep-index\"`),\nbut I suspect that Git will still not allow you to hide the existing\ncommand.\n\nIf you are willing to switch to a new command, you can fix this\neasily. For example, either of these would do what you want whenever\nyou run `git stsh` (note the missing \"a\" in \"stash\") or `git stashki`:\n    `git config \"alias.stsh = stash --keep-index\"`\n    `git config \"alias.stashki = stash --keep-index\"`\n\nJason\n"}]}