参考: https://stackoverflow.com/questions/3239274/git-commit-fails-due-to-insufficient-permissions
问题
git add
或者git commit
之后报错:
error: insufficient permission for adding an object to repository database .git/objects
error: insufficient permission for adding an object to repository database .git/objects
error: Error building trees
解决
sudo chown -R cygr-0101-01-0133 *
cd .git
sudo chown -R cygr-0101-01-0133 *
核心原因
https://stackoverflow.com/questions/28832815/git-commands-require-sudo-on-osx
其实就是我们的项目git clone
的时候, 需要系统sudo
权限, 和我们git安装与关系. 应该是ssh需要系统权限. 即使操作了, 以后git fetch
和 git push
也需要权限. 但最起码, 保存不恶心了...
解决办法
chown -R <user> myproject