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

Weird behavior/bug for git clean in untracked directory

From
DSDavid Spångberg <david@tunna.org>
Date
Oct 4, 2017, 19:06 UTC
Message-ID
<8760bu7mxh.fsf@tunna.org>
Hello

I'm a little bit confused about the behavior of git clean when trying to clean multiple files/directories at once. For instance if I create two directories with an empty file in an new git repository as such:

  mkdir tmprepo
  cd tmprepo
  git init
  mkdir a b
  touch a/file b/file

and try to clean both these files at the same time with git clean as such:

  git clean -f a/file b/file

then git will not clean any of the files. However, if I separate the cleaning into two separate calls like this:

  git clean -f a/file
  git clean -f b/file

then both directories will be cleaned. The git clean manual page suggests git clean should support multiple paths/directories:

  SYNOPSIS
         git clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] <path>...
  DESCRIPTION
         ...
         If any optional <path>... _arguments_ are given, only those _paths_ are affected.

The expected behavior for me would be that there should be no difference between the first `git clean...' with two files and the two `git clean...' with one file each.

I've tested on the following git versions so far:
  * 2.1.4
  * 2.14.2
  * 2.14.2.959.g6663358d3 (currently latest on next branch)

Best regards, David

Message 1 of 1 in “Weird behavior/bug for git clean in untracked directory”
  1. David SpångbergOct 4, 2017

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.