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

Re: [PATCH v1 1/1] git stash needing mkdir deletes untracked file

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 15, 2023, 18:03 UTC
Message-ID
<xmqqcyzoji7u.fsf@gitster.g>
In-Reply-To
<9f76de24-d337-ed41-fb81-888dba0b1656@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
> I don't think we should be treating "git stash" as a special case here
> - commands like "git checkout" should not be removing untracked files
> unprompted either.

Yeah, I tend to agree. "git checkout branch path" should overwrite a leftover "path" in the working tree in response to such an explicit request, and that should equally apply for a request with pathspec e.g. "git checkout branch .", as the latter is also an explicit "please check out all paths out of the tree-ish of the branch".

But "git checkout branch" in a working tree with untracked "path" should not lose it if "branch" has it as a tracked file.

> I think stopping and telling the user that the file would be
> overwritten as we do in other cases would be better.

Yup, that is what we have done and probably one of the design choices that made us successful.

Show 7 quoted lines
>> Reading the different reports and including own experience,
>> I still think that a directory called ".deleted-by-user"
>> or ".wastebin" or something in that style is a good idea.
>
> I can see an argument for being able to opt-in to that for "git
> restore" and "git reset --hard" but that is a different problem to the
> one here.

Yeah, I tend to agree. If anything, such a trash directory should be kept out-of-line, not inside the working tree. Perhaps in $HOME or somewhere, and not necessarily tied to the use of Git, as the way a file gets "deleted by user" is not necessarily limited to the use of Git.

Previous: Torsten BögershausenNext: Junio C Hamano
Message 13 of 15 in “Lost files after git stash && git stash pop”
  1. Till FriebeJul 21, 2023
  2. Torsten BögershausenJul 22, 2023
  3. Phillip WoodJul 23, 2023
  4. Torsten BögershausenJul 23, 2023
  5. Phillip WoodJul 24, 2023
  6. 1/1 git stash needing mkdir deletes untracked filetboegi@web.de, Aug 8, 2023
  7. Torsten BögershausenAug 8, 2023
  8. Eric SunshineAug 8, 2023
  9. Phillip WoodAug 9, 2023
  10. Torsten BögershausenAug 9, 2023
  11. Phillip WoodAug 15, 2023
  12. Torsten BögershausenAug 15, 2023
  13. Junio C HamanoAug 15, 2023
  14. Junio C HamanoAug 9, 2023
  15. Phillip WoodAug 15, 2023

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.