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

git stash save -u deletes ignored files without stashing them

From
MBMichael Brade <brade@kde.org>
Date
Dec 13, 2015, 07:51 UTC
Message-ID
<566D236D.5090904@kde.org>
Hi,

and it does so if .gitignore has not been committed yet. This is with git version 2.6.3. To reproduce:

mkdir test cd test git init

echo "test" > test echo "something.txt" > .gitignore

git add test .gitignore git commit -a -m "init"

mkdir node_modules echo "something" > node_modules/file.txt echo "node_modules" >> .gitignore

git stash save -u

Now node_modules will be deleted even though it was ignored at the time of the "git stash save -u". Apparently .gitignore is reverted first, then the cleanup is done taking the new state of .gitignore into account where node_modules is now untracked and not ignored anymore, thus deleting it.

I think this should be considered a bug that can cause data loss, even if only in rare cases.

thanks,
  Michael
PS: I'm not subscribed.
Next: Kevin Locke
Message 1 of 2 in “git stash save -u deletes ignored files without stashing them”
  1. Michael BradeDec 13, 2015
  2. Kevin LockeFeb 4, 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.