RE: [Feature request] Add -u option to git rm to delete untracked files
On May 27, 2020 8:45 AM, Ðoàn Tr?n Công Danh wrote:
Show 17 quoted lines
> To: Erik Janssen <eaw.janssen@chello.nl>
> Cc: git@vger.kernel.org
> Subject: Re: [Feature request] Add -u option to git rm to delete untracked
> files
>
> On 2020-05-26 23:21:23+0200, Erik Janssen <eaw.janssen@chello.nl> wrote:
> > 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)).
A git alias could easily be set up to do this, of course dangerous because of what git-clean does without any arguments:
git config --global alias.rmu 'clean -f --'
Show 11 quoted lines
> 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".