Add *, but sibling is being ignored

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

  • .gitignore not working with fresh repo
  • .gitignore ignoring whitelisted folder
  • Git ignore this kind of files?
  • Git is dropping my .gitignore files at checkout
  • Creating directory/file name rules for .gitignore
  • Tell git never to update a file
  • 'Desynchronize' a PHP config file with Git
  • directory in .gitignore is not deleted from repository
  • 2 Solutions collect form web for “Add *, but sibling is being ignored”

    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.

    When you use the wildcard *, it will be expanded by your shell on Unix systems. Thus, running git add assets/* is the equivalent of explicitly adding files beneath assets/avatars.

    For example, if I have two files:

    assets/file1.txt
    assets/avatars/file2.txt
    

    Then running git add assets/* is expanded to:

    git add assets/file1.txt assets/avatars/file2.txt
    

    So git complains that you are instructing it to add an ignored file. If you want to avoid this message, you can quote the * to allow git to do the globbing. This will instruct git to expand your paths, paying attention to the .gitignore file. For example:

    git add assets/\*
    

    Produces no warnings and stages only the appropriate files, in this example, assets/file1.txt.

    Git Baby is a git and github fan, let's start git clone.