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

Re: git clean -Xdf affects parent and sibling directories

From
JBJan Berges <jan.berges@uni-bremen.de>
Date
Feb 8, 2025, 09:43 UTC
Message-ID
<111052b2-b64e-4146-b8eb-45ee27402ddc@uni-bremen.de>
In-Reply-To
<xmqq4j15fnx1.fsf@gitster.g>
On 2/7/25 22:24, Junio C Hamano wrote:
> The command should take the usual pathspec, so "git clean ." should work as expected.

Thank you for the explanations! I tried again with "git clean -Xf -- ." and this command still removes parent and sibling content. This seems to be at odds with the manual: "If any optional <pathspec>... arguments are given, only those paths that match the pathspec are affected."

As far as I can see, if <pathspec> is untracked and ignored, the command goes to the topmost ignored directory of the tree and cleans from there.

In the worst case, GIT_WORK_TREE=$HOME, GIT_DIR tracks dotfiles, and all other directories such as ~/Documents/ are ignored. Running the command in ~/Documents/path/to/another/repository/ would remove everything under ~/Documents/. (This is not exactly what I did; I did not lose any files. In any case, thanks for the advice to always do a dry run first!)

Jan
Previous: Junio C Hamano
Message 3 of 3 in “git clean -Xdf affects parent and sibling directories”
  1. Jan BergesFeb 7, 2025
  2. Junio C HamanoFeb 7, 2025
  3. Jan BergesFeb 8, 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.