git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git stash can recursively delete a directory with no warning

From
RYRussell Yanofsky <russ@yanofsky.org>
Date
Nov 16, 2016, 20:19 UTC
Message-ID
<CA+ip-Bt96KRfv_UdYKDTEzDgR0QLtPshsZszXsnCw8wRTBG2WQ@mail.gmail.com>

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

Message 1 of 1 in “git stash can recursively delete a directory with no warning”
  1. Russell YanofskyNov 16, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.