git stash and pop shows file no longer marked as moved?

If you haven’t already popped your stash, do:

git stash pop --index

This correctly preserves moved (but not committed) file relationships in a stash. According to git help stash:

If the –index option is used, then tries to reinstate not only the working tree’s changes, 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).

If you’ve already popped your stash and want to re-create the moved relationship, do:

git rm --cached file1

This removes the “old” unmoved file from the index:

Use this option to unstage and remove paths only from the index

Leave a Comment