Re: stash push/pop unstages files?

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

 



On Sun, Sep 5, 2021 at 10:12 AM Yuri <yuri@xxxxxxxxx> wrote:
> In one sub-directory I altered some files, added a directory with files
> and added the changes (git add .)
>
> Then I called 'git stash push && git stash pop'.
>
> After this the newly added directory remained in the staged status, but
> altered files became unstaged.
>
> Is this an intended behavior?

Yes.

> Why stash push/pop unstages files? Shouldn't it preserve the directory
> as-is?

It does, *provided* you invoke the pop step with `--index`.

When `git stash push` makes a stash, it saves both the index
(staging area) and working tree, as two separate commits.

Later, at the time you apply the saved stash, you choose
whether to use the saved index / staging-area (`--index`) or to
discard it (no `--index`).  The apply step uses the saved working
tree in all cases, and if you also stashed untracked files with
`-u` or `-a`, it uses this third commit as well.

The `pop` command is just `apply` followed by `drop` if the
application succeeds.

Chris



[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