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

I used to be able to do, from my App folder:

git add .
git commit -m "commit details"
git push

and the latest version of my app on my local machine would be backed up on in my master repo, on github.

  • How to fix permission denied for .git/ directory when performing git push?
  • Now, when I get as far as just the git add . command, I get:

    mycompaq@ubuntu:~/myapp$ git add .
    error: insufficient permission for adding an object to repository database .git/objects
    error: app/views/reviews/update.js.erb: failed to insert into database
    error: unable to index file app/views/reviews/update.js.erb
    fatal: updating files failed

    I read in a message on Stackoverflow the way to overcome a similar problem was with:

    chown -R user:user /project/directory

    But seeing as I got in a whole load of trouble in the first place by running commands I wasn’t sure about, I want to know if this is the command for me. What does it do? Can it be undone?

    What should the exact syntax be, if the user is ‘Christophe’, and the folder where my Rails app is stored is called ‘myapp’. I mean should it be

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

    Sorry for all the questions.

  • How to see the changes between two commits without commits in-between?
  • How to specify where Git LFS files will be stored?
  • Git checkout <latest branch you were working on> command
  • How git works when two peers push changes to same remote simultaneously
  • Trying to clone a repository in git, getting a error
  • git recover deleted file where no commit was made after the delete
  • 2 Solutions collect form web for “github error: insufficient permission for adding an object to repository database”

    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

    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.


    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.

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

    2) Get your username by typing


    3) Enter this command

    sudo chown -R dwain .git/*

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