Git – can’t add all files to git due to permissions


I want to add all the files in the current directory to git:

git add .
error: open(".mysql_history"): Permission denied
fatal: unable to index file .mysql_history

That's fine. That file happens to be in this directory and owned by root. I want to add all other files. Is there a way to do that without having to manually add each file by hand?

I know that I could add the file to exclude or .gitignore, but I'd like to have it just ignore things based on permissions (there's a good chance other files like this will end up in the directory, and adding them to .gitignore all the time is a pain).

Best Solution

Use git add --ignore-errors .

This will still give an error for the unreadable file(s), but not a fatal one. The other files will be added.