github error: insufficient permission for adding an object to repository database

  1. Make sure you're inside the repository where you're getting the error.

  2. Get your username by typing

    whoami

  3. Enter this command

sudo chown -R your_user_name .git/*


chown [ -f ] [ -h ] [ -R ] Owner [ :Group ] { File ... | Directory ... }

From the man page

The chown command changes the owner of the file specified by the File parameter to the user specified by the Owner parameter. The value of the Owner parameter can be a user ID or a login name found in the /etc/passwd file. Optionally, a group can also be specified. The value of the Group parameter can be a group ID or a group name found in the /etc/group file.

About the -R option

-R
Descends directories recursively, changing the ownership for each file. When a symbolic link is encountered and the link points to a directory, the ownership of that directory is changed but the directory is not further transversed.

So

chown -R user:christophe /myapp/app/views/reviews/update.js.erb

Would change the owner of the update.js.erb file to the user user in the group christophe, which is probably not what you want.

In your case changing the owner of the repo to yourself, i.e.

sudo chown -R christophe /path/to/your/local/repo

should suffice.

If you don't know your user name, you can find it out with the whoami command.

Tags:

Git

Github

Chown