If you’ve had multiple files with varying owners in a git repo, and have used sudo git <anything>, then the owners of certain folders in .git/objects may also have root ownership.

$ git add .
error: insufficient permission for adding an object to repository database .git/objects
error: <file> failed to insert into database
error: failed to index file '<file>'
fatal: adding files failed

To fix this, normalize the ownership of .git/objects:

$ sudo chown -R misha:misha .git/objects

(if you are not misha, substitute misha with your username)

git