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

Re: [Feature request] Add -u option to git rm to delete untracked files

From
Đoàn Trần Công Danh <congdanhqx@gmail.com>
Date
May 27, 2020, 12:44 UTC
Message-ID
<20200527124445.GB2013@danh.dev>
In-Reply-To
<1098602171.79502.1590528083387@mail.ziggo.nl>
On 2020-05-26 23:21:23+0200, Erik Janssen <eaw.janssen@chello.nl> wrote:
Show 8 quoted lines
> Would it be feasible to add a -u option to git rm to specify that
> I also want a file deleted if it is not tracked by git?
> Currently, git rm -f can remove files in whatever state it seems,
> except when it is untracked. 
> By allowing a -u option (-u: also delete untracked files) I would be
> sure that the file is gone while it would also make sure that it
> doesn't break past behaviour where people perhaps rely on git rm to
> leave untracked files alone.

I _think_ remove untracked file is pretty much risky operation, and it should be done separately/independently (via git-clean(1)).

Let's assume we have -u|--untracked, nothing (probably) can stop our users from:

	git rm -u src
	git rm -u .

Even git-clean(1) requires either --force or --interactive because it's too much risky to begin with.

If we think Git as a FileSystem, its rm should only care about its tracked file. I prefer to just rm(1) instead of "git-rm -u".

-- 
Danh
Previous: Jeff KingNext: Randall S. Becker
Message 3 of 5 in “[Feature request] Add -u option to git rm to delete untracked files”
  1. Erik JanssenMay 26, 2020
  2. Jeff KingMay 27, 2020
  3. Đoàn Trần Công DanhMay 27, 2020
  4. Randall S. BeckerMay 27, 2020
  5. Erik JanssenMay 27, 2020

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.