git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* defaulting git stash to "--keep-index"
@ 2013-11-20  1:50 Tim Chase
  2013-11-20  2:08 ` Nathan Collins
  2013-11-20  2:10 ` Jason St. John
  0 siblings, 2 replies; 3+ messages in thread
From: Tim Chase @ 2013-11-20  1:50 UTC (permalink / raw)
  To: git

Having lost "add -p" work enough times when stashing, I finally
dug into the docs to see how to prevent it, discovering that
"--keep-index" does exactly what I want.  However, now I have trouble
remembering to add the "--keep-index" until after I've shot myself in
the foot.  How do I go about getting "git stash" to default to
"--keep-index"?  I've played around a little with aliases, but
haven't found the right incantation.

The existence of "--no-keep-index" suggests there's some way to make
"--keep-index" the default, but I'm missing it.

Thanks,

-tkc

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

* Re: defaulting git stash to "--keep-index"
  2013-11-20  1:50 defaulting git stash to "--keep-index" Tim Chase
@ 2013-11-20  2:08 ` Nathan Collins
  2013-11-20  2:10 ` Jason St. John
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Collins @ 2013-11-20  2:08 UTC (permalink / raw)
  To: Tim Chase; +Cc: git

On Tue, Nov 19, 2013 at 5:50 PM, Tim Chase <git@tim.thechases.com> wrote:
> Having lost "add -p" work enough times when stashing, I finally
> dug into the docs to see how to prevent it, discovering that
> "--keep-index" does exactly what I want.

Note that 'git stash (pop | apply) --index' will reinstate the index
as it was at stash time, regardless of whether '--keep-index' was used
to create the stash.  In other words, your index is not "lost" when
you stash.

Also note: when you 'git stash --keep-index', although your index
remains intact, the changes in the your index still become part of the
stash.  Hence, any changes to the indexed portion of your files after
a stash usually result in a conflict on subsequent 'git stash pop'.
This confuses me quite a lot, since I'd expect a main use case of 'git
stash --keep-index' to be fixing a up a commit, but then any fixes
cause a conflict :P

Cheers,

-nathan

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

* Re: defaulting git stash to "--keep-index"
  2013-11-20  1:50 defaulting git stash to "--keep-index" Tim Chase
  2013-11-20  2:08 ` Nathan Collins
@ 2013-11-20  2:10 ` Jason St. John
  1 sibling, 0 replies; 3+ messages in thread
From: Jason St. John @ 2013-11-20  2:10 UTC (permalink / raw)
  To: Tim Chase; +Cc: git

On Tue, Nov 19, 2013 at 8:50 PM, Tim Chase <git@tim.thechases.com> wrote:
> Having lost "add -p" work enough times when stashing, I finally
> dug into the docs to see how to prevent it, discovering that
> "--keep-index" does exactly what I want.  However, now I have trouble
> remembering to add the "--keep-index" until after I've shot myself in
> the foot.  How do I go about getting "git stash" to default to
> "--keep-index"?  I've played around a little with aliases, but
> haven't found the right incantation.
>
> The existence of "--no-keep-index" suggests there's some way to make
> "--keep-index" the default, but I'm missing it.
>
> Thanks,
>
> -tkc
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

git-config(1) states that you cannot hide existing Git commands. In
other words, aliasing "git stash" to "git stash --keep-index" is not
possible. You could try playing around with the exclamation point
version (e.g. `git config "alias.stash = !git stash --keep-index"`),
but I suspect that Git will still not allow you to hide the existing
command.

If you are willing to switch to a new command, you can fix this
easily. For example, either of these would do what you want whenever
you run `git stsh` (note the missing "a" in "stash") or `git stashki`:
    `git config "alias.stsh = stash --keep-index"`
    `git config "alias.stashki = stash --keep-index"`

Jason

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

end of thread, other threads:[~2013-11-20  2:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-20  1:50 defaulting git stash to "--keep-index" Tim Chase
2013-11-20  2:08 ` Nathan Collins
2013-11-20  2:10 ` Jason St. John

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 NNTP newsgroup(s).