{"thread":{"id":"40551","subject":"bug report: `git stash save -u` deletes directory whose contents are .gitignored","startedAt":"2015-10-13T22:48:03Z","lastAt":"2015-10-13T22:48:03Z","messageCount":1,"participants":["lennart spitzner"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"271600","messageId":"561D8A23.2090601@web.de","threadId":"40551","inReplyTo":null,"subject":"bug report: `git stash save -u` deletes directory whose contents are .gitignored","fromName":"lennart spitzner","fromEmail":"len48@web.de","sentAt":"2015-10-13T22:48:03Z","receivedAt":"2015-10-13T22:48:03Z","isPatch":false,"sender":{"key":"len48@web.de","avatar":null},"body":"hi,\n\n- `git stash save -u` deletes a directory, even though the _contents_\nof that directory are .gitignored (e.g. \"foo/*\" in .gitignore).\nDetailed reproduction below.\n- The behaviour is not present when instead .gitignoring the directory\nitself (e.g. \"foo\"). This does imo not excuse the behaviour of the\ndescribed case.\n- The behaviour is not present with just `git stash save`.\n- The expected behaviour is: Only files listed in `git status` are\nstashed away; other things are left untouched. Potential exception:\nempty directories.\n- I am aware that `git stash save -u` is supposed to have semantics\ninvolving the equivalent of `reset --hard` and `clean -f`. Neither of\nthose expose the directory-deletion behaviour.\n\nadditional comments, not directly relevant to this bug:\n- both `git stash save; git stash pop` and `git stash save -u; git\nstash pop` should ideally behave as an \"identity effect\". The latter\nmight affect the index (i.e. have an effect equivalent to `git reset`\nor something in that direction). Any other effect / special cases are\nbad interface design imo. If a differing design was chosen on purpose,\ni am thankful for pointers on the reasoning.\n- no, i luckily did not truely lose files due to the current behaviour.\n\nlennart\n\n----\n\nreproduction:\n\n> git init\nInitialized empty Git repository in $SOMEDIR/.git/\n> mkdir ignore-contents\n> echo \"ignore-contents/*\" > .gitignore\n> git add .gitignore\n> git commit -m \"initial\" > /dev/null\n> touch ignore-contents/blah.txt\n> touch abc.txt\n> git status\nOn branch master\nUntracked files:\n  (use \"git add <file>...\" to include in what will be committed)\n\n  abc.txt\n\nnothing added to commit but untracked files present (use \"git add\" to\ntrack)\n> ls -1a\n.\n..\nabc.txt\n.git\n.gitignore\nignore-contents\n> git stash save -u\nSaved working directory and index state WIP on master: adc468b initial\nHEAD is now at adc468b initial\n> ls -1a\n.\n..\n.git\n.gitignore\n> git stash pop &> /dev/null\n> ls -1a\n.\n..\nabc.txt\n.git\n.gitignore\n> git --version\ngit version 2.6.1\n"}]}