git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Add config option to make "--keep-index" the default for "git stash push"
@ 2018-10-22  8:11 Ralf Jung
  2018-10-24  1:50 ` brian m. carlson
  0 siblings, 1 reply; 2+ messages in thread
From: Ralf Jung @ 2018-10-22  8:11 UTC (permalink / raw)
  To: git

Hi all,

I have been repeatedly bitten by the default behavior of `git stash` to stash
not just the unstaged but also the staged changes, and then `git stash pop`
making all changes unstaged. This means `git stash && git stash pop`, per
default, loses information, and when I just spent 10min carefully selecting
hunks to be staged that's quite frustrating.

I found that for myself, I usually expect `git stash` to only stash the changes
that are not yet staged.  So I'd like to configure git such that `--keep-index`
is the default.  That would also fix the information loss I mentioned above.
(By now I am also aware of `git stash pop --index`, but (a) that's not the
default either and (b) its documentation indicates it might not always work very
well.)  However, going over the `git-config` man page, I have not found any way
to change the default behavior.  Is that possible somehow?  And if not, could
you consider this a feature request to add such an option?

Kind regards,
Ralf

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Add config option to make "--keep-index" the default for "git stash push"
  2018-10-22  8:11 Add config option to make "--keep-index" the default for "git stash push" Ralf Jung
@ 2018-10-24  1:50 ` brian m. carlson
  0 siblings, 0 replies; 2+ messages in thread
From: brian m. carlson @ 2018-10-24  1:50 UTC (permalink / raw)
  To: Ralf Jung; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 1887 bytes --]

On Mon, Oct 22, 2018 at 10:11:50AM +0200, Ralf Jung wrote:
> Hi all,
> 
> I have been repeatedly bitten by the default behavior of `git stash` to stash
> not just the unstaged but also the staged changes, and then `git stash pop`
> making all changes unstaged. This means `git stash && git stash pop`, per
> default, loses information, and when I just spent 10min carefully selecting
> hunks to be staged that's quite frustrating.
> 
> I found that for myself, I usually expect `git stash` to only stash the changes
> that are not yet staged.  So I'd like to configure git such that `--keep-index`
> is the default.  That would also fix the information loss I mentioned above.
> (By now I am also aware of `git stash pop --index`, but (a) that's not the
> default either and (b) its documentation indicates it might not always work very
> well.)  However, going over the `git-config` man page, I have not found any way
> to change the default behavior.  Is that possible somehow?  And if not, could
> you consider this a feature request to add such an option?

First, let me say that I'm speaking for myself and not the whole list.
Other people may have other opinions, and some may want to see a patch
before deciding.

Personally, I am hesitant about such an option, since I know people use
stash in scripts and hooks (whether that's a good idea or not), and
ending up with an unclean tree after git stash would be surprising and
could potentially cause data loss.  (I have a co-worker who is doing
exactly this.)

We do have a --no-keep-index option, so there is an out for people who
don't want that behavior, and maybe that's enough to avoid problems.  I
usually deal with this situation by using an alias, which lets me have
more control over the exact behavior I want.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 868 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-24  3:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-22  8:11 Add config option to make "--keep-index" the default for "git stash push" Ralf Jung
2018-10-24  1:50 ` brian m. carlson

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).