tags:

views:

867

answers:

3

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 in a pain).

+3  A: 

Would it help if you added that file to your .gitignore file? So all other files would be versioned and that file would get ignored (unless you need it).

mwilliams
+3  A: 

Just exclude the file. You can add .mysql_history to a .gitignore file, or add it to .git/info/exclude.

Adding an entry to .gitignore will propagate the setting with the repo (since .gitignore is stored with the repo); adding it to .git/info/exclude makes it "personal" because this file is not propagated with the repo. Either way, .mysql_history will be ignored by git-add and friends.

You can read more about ignoring files with Git on this man page.

mipadi
+3  A: 

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.

matli
This works, but only on git 2.6 and up it seems :)
singpolyma