Re: Bug in git-stash

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

 



Hi!

> The stash contains the diff between HEAD and the unstaged file

This is expected behavior. From the git stash manpage:

"""
All changes already added to the index are left intact.
"""

This is, it works just like running `git stash` but without
touching the index and keeping the already staged changes in
the working directory.

But still, each stash entry is two commits, one containing
the state of the index and other containing the state of the
working tree. You can see that in git stash manpage, in the
section "DISCUSSION". This way, you can operate on them like
any other commit.

More specifically, if you want the stashed changes from the
index to the working directory, you can run:

git cherry-pick -n -m 2 stash

where:

-n: cherry-picks the content without creating a commit

-m 2: given that the last commit is a merge commit whose
  parents are the HEAD at the moment of stashing changes (the
  first parent) and the commit containing the state of the
  index (the second parent), apply the changes based on the
  second parent (i.e. what was in the working directory but
  not in the index)

- stash: this is the stash reference (just like any other
  reference, like branches or tags). It points to the last
  commit of the last stash entry. If you want to use other
  entry, follow the reflog syntax (i.e. stash@{1})




[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