Re: [RFC] git clean --local
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 2, 2018, 04:43 UTC
- Message-ID
- <xmqqo9a4ilm8.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <xmqqsgzgiyk2.fsf@gitster-ct.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 10 quoted lines
> Cameron Boehmer <cameron.boehmer@gmail.com> writes: > >> 1) add a new flag >> -l, --local >> Do not consult git config --global core.excludesFile in >> determining what files git ignores. This is useful in conjunction with >> -x/-X to preserve user files while removing build artifacts. > ... > But it might be useful as an option that affects any "git" command, > e.g. "git --local-config-only clean". I dunno.
If you only want to say "there is no global excludes file", perhaps
$ git -c core.excludesFile=/dev/null clean -x
may be sufficient, so for that particular use case, there is no need to introduce a new command, I'd think.
In the longer term, however, I think we would want to introduce a distinction among ignored files---we only support "ignored and expendable" class, but not "ignored but precious" class. With the latter class introduced, it would make sense for "git clean -x/-X" to notice that a path is ignored but precious and keep it. If a dir/foo is ignored, dir/bar is tracked in commit A that is currently checked out, and there is no dir/ directory in commit B, checking out commit B would remove dir/foo (because the last tracked file in the directory goes away and all remaining files in the directory would be ignored but expendable). But if we introduced a new "ignored but precious" class and made dir/foo a member of such a class, then you will be prevented from checkout out B until you do something about dir/foo that is now "precious".