git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guillem Jover <guillem@hadrons.org>
To: git@vger.kernel.org
Subject: Add a way to disable «git clean» per repo
Date: Sat, 1 Apr 2023 22:50:16 +0200	[thread overview]
Message-ID: <ZCiZCM+AAUnjp4Ml@thunder.hadrons.org> (raw)

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

             reply	other threads:[~2023-04-01 21:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-01 20:50 Guillem Jover [this message]
2023-04-03 17:36 ` Add a way to disable «git clean» per repo Junio C Hamano
2023-04-09 17:01   ` Guillem Jover
2023-04-10 13:32     ` Thomas Guyot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZCiZCM+AAUnjp4Ml@thunder.hadrons.org \
    --to=guillem@hadrons.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).