threads / discuss / 21243

why no "ignore" command on git

Subject: why no "ignore" command on git

## tl;dr

6 messages between Oct 14, 2009 and Oct 15, 2009.

replies: 5people: 6as markdown or json

Ralf Thielow· Oct 14, 2009, 22:35 UTC · lore
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· Oct 14, 2009, 23:02 UTC · re: Ralf Thielow · lore

Re: why no "ignore" command on git

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:
Show 22 quoted lines
> 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· Oct 15, 2009, 04:20 UTC · re: Ralf Thielow · lore

Re: why no "ignore" command on git

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.
[...]
Show 5 quoted lines
> 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· Oct 15, 2009, 09:29 UTC · re: Wesley J. Landaker · lore

Re: why no "ignore" command on git

Hi,
On Wed, 14 Oct 2009, Wesley J. Landaker wrote:
Show 14 quoted lines
> 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· Oct 15, 2009, 11:31 UTC · re: Wesley J. Landaker · lore

Re: why no "ignore" command on git

"Wesley J. Landaker" <wjl@icecavern.net> writes:
Show 14 quoted lines
> 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· Oct 15, 2009, 15:52 UTC · re: Matthieu Moy · lore

Re: why no "ignore" command on git

On Thu, Oct 15, 2009 at 01:31:01PM +0200, Matthieu Moy wrote:
Show 11 quoted lines
> >> 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

← back to recent threads