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

Add a way to disable «git clean» per repo

From
GJGuillem Jover <guillem@hadrons.org>
Date
Apr 1, 2023, 20:50 UTC
Message-ID
<ZCiZCM+AAUnjp4Ml@thunder.hadrons.org>
Hi!
[ I initially filed this in the Debian bug tracking system as it
  seemed to me that filing a feature request on a mailing list had
  a great potential to get lost. But I guess I can try anyway. :) ]

For repositories that are not tracking code, say when storing your ~/ under git, or to store say collections of data files such as photos, texts or similar, you might end up using .gitignore to unclutter «git status». The problem is that both ignored and non-ignored untracked files can be “precious”, as in not version-tracked by losing them might imply data loss.

Accidentally running «git clean -xdf» or «git clean -Xdf» might be catastrophic there. But for the ~/ case (or any such tracking in a parent of git trees, this is even worse, as an accidental «cd» too much while in some code repo might end up accidentally recursively running those «git clean» on an unexpected working tree and all of its subdirectories (except for other git working trees).

I tend to be rather careful with this, but I recently had a scare where this happened to me, and lost a few (not essential) files before I noticed and Ctrl-C'd git. I then set out to try to disable git clean on these situations, but I see no way to do that as aliases do not work with built-ins, and adding a ~/bin/git wrapper to check for this seems extremely cumbersome.

It would thus be nice if there was an option that could be set to completely disable «git clean» on a repo. I guess it might make sense to disable for any untracked file, or perhaps for ignored and/or non-ignored. So that these kind of work trees could be protected.

Thanks, Guillem

Next: Junio C Hamano
Message 1 of 4 in “Add a way to disable «git clean» per repo”
  1. Guillem JoverApr 1, 2023
  2. Junio C HamanoApr 3, 2023
  3. Guillem JoverApr 9, 2023
  4. Thomas GuyotApr 10, 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.