Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File state lost after git stash command

Tags:

git

git-stash

echo Hello. > a.txt
git add .
echo Bye. >> a.txt
git status -s
>>> AM

We can see state is AM,
But on doing the following

git stash
git stash pop
git status -s
>>> A

State is A. Why is the M state lost?

like image 441
piaolingxue Avatar asked Jan 22 '26 11:01

piaolingxue


1 Answers

It is the expected behavior. To reconstruct it as you expect (save A & M) use

git stash pop --index

From documentation:

git-stash(1):

If the --index option is used, then tries to reinstate not only the working
tree’s hanges, but also the index’s ones. However, this can fail, when you have
conflicts (which are stored in the index, where you therefore can no longer apply
the changes as they were originally).
like image 161
the.malkolm Avatar answered Jan 24 '26 08:01

the.malkolm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!