Re: [BUG] git stash --keep-index undeletes file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 04/16, Christian Vetter wrote:
> Steps to reproduce
> + mkdir git-stash-test
> + cd git-stash-test
> + git init
> + touch file
> + git add file
> + git commit -m init
> + git rm file
> + git stash push --keep-index
>  
>  
> Result: 
> `git status` gives this output:
> > On branch master
> > Changes to be committed:
> >   (use "git reset HEAD <file>..." to unstage)
> > 
> >         deleted:    file
> > 
> > Untracked files:
> >   (use "git add <file>..." to include in what will be committed)
> > 
> >         file

I think this is the correct result.  --keep-index keeps the changes
that are in the index, in this example that 'file' is deleted, but
restores the working tree to 'HEAD', where 'file' existed.  It's now
showing up as untracked because Git doesn't know about it.

Similarly if you just did 'git stash push' without --keep-index,
'file' would be restored in your working tree, but 'git status' would
report the working tree as clean because it would also be restored in
the index.

> Expected: 
> `git status` gives this output:
> > On branch master
> > Changes to be committed:
> >   (use "git reset HEAD <file>..." to unstage)
> > 
> >         deleted:    file

This is what you get before 'git stash push --keep-index'.  Do you
think the documentation on '--keep-index' is unclear, and could be
improved?  Or why did you think that this is the correct output?

> Verified on:
> + Windows 10, git version 2.21.0.windows.1 
> + Ubuntu 14.04, git version 2.21.0



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux