threads / discuss / 44499

git stash can recursively delete a directory with no warning

Subject: git stash can recursively delete a directory with no warning

## tl;dr

One message between Nov 16, 2016 and Nov 16, 2016.

replies: 0people: 1as markdown or json

Russell Yanofsky· Nov 16, 2016, 20:19 UTC · lore

Using git 2.10.1, I recently lost the contents of an entire directory by running a "git stash" command. I don't know if this known behavior, but it seems pretty dangerous. To trigger the bug, all you have to do is check out a repository containing a symlink, delete the symlink, and then create a directory with files at the path where the deleted symlink was. After this, running "git stash" will recursively delete the directory, leaving no way to recover the data.

Here are minimal steps to reproduce:

mkdir test-repo cd test-repo git init ln -s location symlink git add symlink git commit -m'add symlink' rm symlink mkdir symlink echo important-data > symlink/important-data git stash # recursively deletes entire contents of "symlink" directory

← back to recent threads