# why no "ignore" command on git

6 messages from 2009-10-14 to 2009-10-15. Participants: Ralf Thielow, Scott Wiersdorf, Wesley J. Landaker, Johannes Schindelin, Matthieu Moy, Jeff King.
Thread: https://gitlist.dev/t/21243

## Ralf Thielow, 2009-10-14 22:35

Subject: why no "ignore" command on git
Message-ID: <42efdea40910141535g23a50b87p9b6c4a0fde7e842e@mail.gmail.com>
URL: https://gitlist.dev/e/42efdea40910141535g23a50b87p9b6c4a0fde7e842e%40mail.gmail.com

```
Hello,

why does git don't have an "ignore" command, to ignore some files or
directories all the time.
In many project file structures you have IDE specified project files
or directories which
should not be tracked on git. All the time git says that you can add
these files, this is not
usable if you want to add many files with the "git add ." command.
I read on some pages by a google search that you can create
a ".gitignore" directory or something like that. But you had to do
this manually.

why there is no "ignore" command on git?

best regards

Ralf

```

## Scott Wiersdorf, 2009-10-14 23:02

Subject: Re: why no "ignore" command on git
Message-ID: <20091014230217.GA87543@perlcode.org>
URL: https://gitlist.dev/e/20091014230217.GA87543%40perlcode.org
In-Reply-To: <42efdea40910141535g23a50b87p9b6c4a0fde7e842e@mail.gmail.com>

```
git does have a command to ignore files and directories: it's called
'emacs' (or 'vim' on some systems).

Seriously, the .gitignore file can contain a complex set of patterns
to ignore, and you can have .gitignore files at lower directories in a
hierarchy to override higher ones. This isn't something easily
contained in a simple command.

Scott


On Thu, Oct 15, 2009 at 12:35:23AM +0200, Ralf Thielow wrote:
> Hello,
> 
> why does git don't have an "ignore" command, to ignore some files or
> directories all the time.
> In many project file structures you have IDE specified project files
> or directories which
> should not be tracked on git. All the time git says that you can add
> these files, this is not
> usable if you want to add many files with the "git add ." command.
> I read on some pages by a google search that you can create
> a ".gitignore" directory or something like that. But you had to do
> this manually.
> 
> why there is no "ignore" command on git?
> 
> best regards
> 
> Ralf
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Scott Wiersdorf
<scott@perlcode.org>

```

## Wesley J. Landaker, 2009-10-15 04:20

Subject: Re: why no "ignore" command on git
Message-ID: <200910142220.51725.wjl@icecavern.net>
URL: https://gitlist.dev/e/200910142220.51725.wjl%40icecavern.net
In-Reply-To: <42efdea40910141535g23a50b87p9b6c4a0fde7e842e@mail.gmail.com>

```
On Wednesday 14 October 2009 16:35:23 Ralf Thielow wrote:
> why does git don't have an "ignore" command, to ignore some files or
> directories all the time.
[...]
> I read on some pages by a google search that you can create
> a ".gitignore" directory or something like that. But you had to do
> this manually.
>
> why there is no "ignore" command on git?

You could always make your own git-ignore script, e.g.:

#!/bin/sh
echo "$@" >> .gitignore

```

## Johannes Schindelin, 2009-10-15 09:29

Subject: Re: why no "ignore" command on git
Message-ID: <alpine.DEB.1.00.0910151125240.4985@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0910151125240.4985%40pacific.mpi-cbg.de
In-Reply-To: <200910142220.51725.wjl@icecavern.net>

```
Hi,

On Wed, 14 Oct 2009, Wesley J. Landaker wrote:

> On Wednesday 14 October 2009 16:35:23 Ralf Thielow wrote:
> > why does git don't have an "ignore" command, to ignore some files or
> > directories all the time.
> [...]
> > I read on some pages by a google search that you can create
> > a ".gitignore" directory or something like that. But you had to do
> > this manually.
> >
> > why there is no "ignore" command on git?
> 
> You could always make your own git-ignore script, e.g.:
> 
> #!/bin/sh
> echo "$@" >> .gitignore

Probably it needs to be a little more sophisticated, because of Postel's 
law.

#!/bin/sh

git rev-parse > /dev/null || exit
for f
do
	case "$f" in
	*'[*?]'*)
		# patterns probably are meant to be recursive
		echo "$f"
		;;
	*)
		echo /"$f"
		;;
	esac >> .gitignore
done
git add .gitignore


Ciao,
Dscho

```

## Matthieu Moy, 2009-10-15 11:31

Subject: Re: why no "ignore" command on git
Message-ID: <vpqaazsrj0q.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqaazsrj0q.fsf%40bauges.imag.fr
In-Reply-To: <200910142220.51725.wjl@icecavern.net>

```
"Wesley J. Landaker" <wjl@icecavern.net> writes:

> On Wednesday 14 October 2009 16:35:23 Ralf Thielow wrote:
>> why does git don't have an "ignore" command, to ignore some files or
>> directories all the time.
> [...]
>> I read on some pages by a google search that you can create
>> a ".gitignore" directory or something like that. But you had to do
>> this manually.
>>
>> why there is no "ignore" command on git?
>
> You could always make your own git-ignore script, e.g.:
>
> #!/bin/sh
> echo "$@" >> .gitignore

Sure. OTOH, there are other interesting things a "ignore" command can
do. bzr, for example, has a "bzr ignore" command that can either add
stuff to your .bzrignore, or tell you which pattern cause which file
to be ignored. That's handy sometimes.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Jeff King, 2009-10-15 15:52

Subject: Re: why no "ignore" command on git
Message-ID: <20091015155220.GA12169@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20091015155220.GA12169%40coredump.intra.peff.net
In-Reply-To: <vpqaazsrj0q.fsf@bauges.imag.fr>

```
On Thu, Oct 15, 2009 at 01:31:01PM +0200, Matthieu Moy wrote:

> >> why there is no "ignore" command on git?
> >
> > You could always make your own git-ignore script, e.g.:
> >
> > #!/bin/sh
> > echo "$@" >> .gitignore
> 
> Sure. OTOH, there are other interesting things a "ignore" command can
> do. bzr, for example, has a "bzr ignore" command that can either add
> stuff to your .bzrignore, or tell you which pattern cause which file
> to be ignored. That's handy sometimes.

I wrote a toy patch that did something like that a while ago:

  http://thread.gmane.org/gmane.comp.version-control.git/108671/focus=108842

I don't think there is any reason such a thing could not be included
with git (if it did something more interesting than just echoing its
arguments to .gitignore), but nobody has felt strongly enough about it
yet to actually write something polished.

-Peff

```
