home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] what is the function of --keep-index/--no-keep-index with git stash?

  • Subject: Re: [OCLUG-Tech] what is the function of --keep-index/--no-keep-index with git stash?
  • From: "Robert P. J. Day" <rpjday [ at ] crashcourse [ dot ] ca>
  • Date: Thu, 25 Jun 2015 06:45:26 -0400 (EDT)
On Wed, 24 Jun 2015, Robert P. J. Day wrote:

>   i'm experimenting with variations of "git stash" and i'm a bit
> puzzled by one of the save options. what is the effective difference
> between using --keep-index and using --no-keep-index when saving to
> the stash?

 ... snip ...

  never mind, i finally twigged to what was happening here, but i'd
like someone else to confirm it for me.

  if you do "git stash save", regardless of whether you use
--keep-index or --no-keep-index, exactly the same stash will be
created, and it will incorporate both the state of the working tree
and the state of the index at the time of the stash.  the difference
is that with --keep-index, both the working tree and the index will be
left in the state that matches what was in the index at the time.

  i had thought that those two options would affect what actually went
into the stash but, AFAICT, it's precisely the same in both cases so,
mystery solved.

  however, that brings up the subsequent issue, if i save with
--keep-index, i can then do a "git commit" which saves that staged
content, but when i come back to do a "git stash pop", the stash being
popped will still contain what was earlier staged and then committed,
so i'm assuming the pop operation will understand that and will do a
proper merge to handle that duplicate content, yes?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================