Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't add all files to git due to permissions

Tags:

git

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).

like image 461
singpolyma Avatar asked Dec 10 '08 14:12

singpolyma


People also ask

Why does git fail to add a file?

The folder which is giving you fatal: adding files failed message on git add command is actually implying that there is another . git folder inside the folder. If you navigate to the particular folder address, you can remove the file and put git add. It should work.

How do I change permissions in git?

Open Security for a repository You set Git repository permissions from Project Settings>Repositories. Open the web portal and choose the project where you want to add users or groups. To choose another project, see Switch project, repository, team. Open Project settings>Repositories.

Is there a way to git add all files?

The easiest way to add all files to your Git repository is to use the “git add” command followed by the “-A” option for “all”. In this case, the new (or untracked), deleted and modified files will be added to your Git staging area. We also say that they will be staged.


2 Answers

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.

like image 159
matli Avatar answered Sep 19 '22 12:09

matli


Closing your IDE or whatever that uses the relative files you want to upload solved my problem

like image 22
Tsal Giorgos Avatar answered Sep 23 '22 12:09

Tsal Giorgos