# Wildcards with git rm

2 messages from 2017-10-28 to 2017-10-30. Participants: RPS, Junio C Hamano.
Thread: https://gitlist.dev/t/47053

## RPS, 2017-10-28 11:38

Subject: Wildcards with git rm
Message-ID: <cbb7340e-aa8c-1980-41eb-95cd965d4037@resplendentwebservices.com>
URL: https://gitlist.dev/e/cbb7340e-aa8c-1980-41eb-95cd965d4037%40resplendentwebservices.com

```
git rm doesn't seem to be very useful without the use of shell 
wildcards, especially with the use of a .gitignore file. If a .gitignore 
file is used, the git rm command does not consider the .gitignore file, 
and errs out when an ignored file is present.

In my opinion, git rm should take .gitignore into consideration and 
suppress errors for those files along with all other commands in order 
to target valid repository files in the current version. Also, git rm 
should either remove the ignored files and other present  files in the 
working copy to act like a shell rm command along with existing version 
controlled objects from the version, or skip ignored working copy files 
and err out on files not accounted for in the current version.

Have there been any design considerations on these things?

Jim Lutz


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


```

## Junio C Hamano, 2017-10-30 00:58

Subject: Re: Wildcards with git rm
Message-ID: <xmqqk1zd8nac.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqk1zd8nac.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <cbb7340e-aa8c-1980-41eb-95cd965d4037@resplendentwebservices.com>

```
RPS <jim@resplendentwebservices.com> writes:

> git rm doesn't seem to be very useful without the use of shell
> wildcards, especially with the use of a .gitignore file. If a
> .gitignore file is used, the git rm command does not consider the
> .gitignore file, and errs out when an ignored file is present.

Do you mean

	$ git rm COPY*

would complain about COPYING~ on your filesystem, which would match
the pattern "*~" you have in your .gitignore file, after editing the
tracked COPYING file?

If so, you may choose to tell your shell _not_ to expand wildcards,
as it does not know what is ignored, by doing

	$ git rm COPY\*

instead.  That would allow "git rm" to expand wildcards _with_ the
knowledge of what is and is not ignored.  The shell does not know
(probably you could teach if you wanted to, but it does not want to
know) and care about .gitignore files when it does its wildcard
expansion.

```
