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

Bug report: Folder and files are deleted by git stash -u

From
Tobias Preuss <tobias.preuss@googlemail.com>
Date
Feb 5, 2015, 09:56 UTC
Message-ID
<CADEaiE8zSptYy9GTi4ZZ2bZptbretW6kDM4srmrSqaYeavfFhg@mail.gmail.com>
Hello.

I noticed some bizarre behaviour when using: git stash -u. It deletes folders which contain files configured to be ignored. I actually lost files by this which I could not restore.

Here is how you can reproduce the case.
1. Create a project folder to act as the root of the repository. `cd`
into the directory
2. Create a folder `tracked-folder` with a file `tracked-file` in it.
Add some content to the file.
3. Create a folder `untracked-folder` with a file `untracked-file` in
it. Add some content to the file.
4. Create a file `to-be-stashed`, add some content to the file.
5. Create a `.gitignore` file with the following content: `untracked-file`.
6. Initialize the Git repository: `git init .`
7. Add all files to be tracked: `git add . & git commit`
8. List the current content of the repository: `tree`. It should show
the following:
├── to-be-stashed
├── tracked-folder
│   └── tracked-file
└── untracked-folder
    └── untracked-file
9. Run `git stash -u` and inspect the folder again:
.
└── tracked-folder
    └── tracked-file
10. Run `git stash pop` and inspect the folder once again:
.
├── to-be-stashed
└── tracked-folder
    └── tracked-file
There you are - you just lost the whole folder.

Can you please confirm or deny if this is a bug? Thank you. Best regards, Tobias

Next: Junio C Hamano
Message 1 of 3 in “Bug report: Folder and files are deleted by git stash -u”
  1. Tobias PreussFeb 5, 2015
  2. Junio C HamanoFeb 5, 2015
  3. Junio C HamanoFeb 5, 2015

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.