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

[PATCH 0/3] clean: add `config.exclude` and `--remove-excluded`

From
Ivan Shapovalov <intelfx@intelfx.name>
Date
Feb 10, 2025, 19:14 UTC
Message-ID
<20250210191504.309661-1-intelfx@intelfx.name>

This series extends the concept of "excluded files" in `git clean` to make it useful to protect "precious files" that might be present in a specific developer's working tree (see below).

Specifically, this series adds a `config.exclude` knob to configure "always excluded" files (same as `-e` on the command line), and a `--remove-excluded` flag (intentionally without a short form) to "REALLY remove everything, dammit!"

This might seem like euphemism treadmill, but there is a specific use-case for all of the exclusion methods and options:

.gitignore:     files that _the project_ does not want to track or touch
                (build artifacts)
clean.exclude:  files that _the user_ does not want to track or touch
                (IDE configuration)
git clean -x:   remove build artifacts, but keep precious files
                (when a pristine build is desired)
git clean -x --remove-excluded:
                remove everything, including precious files
                (e.g. for redistribution)

For instance, if I use Sublime Text or JetBrains IDEs to work on projects, I might want to add this to my ~/.gitconfig:

[clean]
  exclude = /*.sublime-*
  exclude = /.idea

Or, if I make use of the Bear compiler wrapper to generate the compilation database in those projects that do not use any of the modern build-systems to automate such generation, I might write:

[clean]
  exclude = /compile_commands.json

This way, even if I run `git clean -fxd` to test a clean build, I do not need to worry about accidentally removing the compilation database that would take a bunch of CPU-time to regenerate.

Ivan Shapovalov (3):
  clean, dir: add and use new helper `add_patterns_from_string_list()`
  clean: rename `ignored` -> `remove_ignored`
  clean: add `config.exclude` and `--remove-excluded`
 Documentation/config/clean.txt | 11 +++++++++++
 Documentation/git-clean.txt    | 22 +++++++++++++++-------
 builtin/clean.c                | 32 +++++++++++++++++++++-----------
 dir.c                          | 15 +++++++++++++++
 dir.h                          |  4 ++++
 5 files changed, 66 insertions(+), 18 deletions(-)
-- 
2.48.1.5.g9188e14f140
Next: Ivan Shapovalov
Message 1 of 9 in “clean: add `config.exclude` and `--remove-excluded`”
  1. 0/3 clean: add `config.exclude` and `--remove-excluded`Ivan Shapovalov, Feb 10, 2025
  2. 1/3 clean, dir: add and use new helper `add_patterns_from_string_list()`Ivan Shapovalov, Feb 10, 2025
  3. 2/3 clean: rename `ignored` -> `remove_ignored`Ivan Shapovalov, Feb 10, 2025
  4. 3/3 clean: add `config.exclude` and `--remove-excluded`Ivan Shapovalov, Feb 10, 2025
  5. Junio C HamanoFeb 11, 2025
  6. Junio C HamanoFeb 11, 2025
  7. Ivan ShapovalovFeb 11, 2025
  8. Junio C HamanoFeb 11, 2025
  9. Ivan ShapovalovFeb 11, 2025

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.