Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add *, but sibling is being ignored

Tags:

git

gitignore

I made a bunch of updates inside a directory and would like to add them, but they sit beside a directory which I have in my .gitignore. Shouldn't git add just ignore that instead of complaining?

How can I add everything and just skip the thing being ignored?

$ git add assets/*
The following paths are ignored by one of your .gitignore files:
assets/avatars
Use -f if you really want to add them.
fatal: no files added
like image 858
Louis W Avatar asked Oct 30 '22 23:10

Louis W


1 Answers

According to documentation, the --ignore-errors flag would just make the command work as you'd like.

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.

Update:

This doesn't work in this case, I guess because the assets/* parameter is expanded by the shell so that the actual parameters received by git add are the expanded list of files and directories and so the failure is explicit.

I've tried this command with good results:

$ git add assets

It works even without the option --ignore-errors because it doesn't try to add the ignored directory below assets.

like image 181
Antonio Pérez Avatar answered Nov 11 '22 09:11

Antonio Pérez