threads / discuss / 30322

git add --ignore-errors doesn't ignore .gitignore errors

Subject: git add --ignore-errors doesn't ignore .gitignore errors

## tl;dr

2 messages between Apr 24, 2012 and Apr 24, 2012.

replies: 1people: 2as markdown or json

Kirill Likhodedov· Apr 24, 2012, 09:13 UTC · lore
Hi,
git add has '--ignore-errors' parameter which, according to the man entry, allows to continue adding even if one of the files failed to add:
 --ignore-errors
           If some files could not be added because of errors indexing them, do not abort the
           operation, but continue adding the others. The command shall still exit with non-zero
           status. The configuration variable add.ignoreErrors can be set to true to make this
           the default behaviour.
However, if the error happens because a file is ignored by Git, git-add aborts, even if "--ignore-errors" is given:
	# git add --ignore-errors .t test2.txt
	The following paths are ignored by one of your .gitignore files:
	.t
	Use -f if you really want to add them.
	fatal: no files added
(in this example '.t' is ignored while 'test2.txt' is not)
Is it a bug or a lack of documentation?
Thanks.

---------------------------------- Kirill Likhodedov JetBrains, Inc http://www.jetbrains.com "Develop with pleasure!"

Junio C Hamano· Apr 24, 2012, 19:46 UTC · re: Kirill Likhodedov · lore

Re: git add --ignore-errors doesn't ignore .gitignore errors

Kirill Likhodedov <Kirill.Likhodedov@jetbrains.com> writes:
Show 12 quoted lines
> Hi,
>
> git add has '--ignore-errors' parameter which, according to the man entry, allows to continue adding even if one of the files failed to add:
>
>  --ignore-errors
>            If some files could not be added because of errors indexing them, do not abort the
>            operation, but continue adding the others. The command shall still exit with non-zero
>            status. The configuration variable add.ignoreErrors can be set to true to make this
>            the default behaviour.
>
> However, if the error happens because a file is ignored by Git,
> git-add aborts, even if "--ignore-errors" is given:

That sounds like the command is behaving exactly as documented. It detected a user error that attempts to add an ignored path. That is totally different from "the contents of the path failed to be indexed" (perhaps due to background virus checker keeping the file open on broken operating system platform) case, which the option tells it to ignore and continue.

← back to recent threads