Re: git clean -Xdf affects parent and sibling directories
- From
- Jan 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