git push… fatal: Unable to create master.lock: File exists

喜夏-厌秋 提交于 2019-12-05 23:15:31

The problem appears to have stemmed from running the expiration code as the super-user (sudo ...). When Git adjusted the remote-tracking branch files, they became owned by (and hence only adjustable by) the super-user.

The fix is to put those files back to the correct owner (in this case ubuntu). One can use a blanket ownership-change, e.g., sudo chown -R ubuntu .git, or a selective one (change only mis-owned files), e.g., as root (or with sudo again, this one is a bit more annoying because of the pipeline) find .git -user root -print0 | xargs -0 chown ubuntu. The only difference, if any, between these would be that chown -R might update more files' ctime (inode-change time) fields (by actually running chown system calls on files already properly owned), which can in turn affect backup systems.

The more general rule is "don't arbitrarily prefix stuff with sudo"—in this case, there was no reason to put sudo in front of the git reflog expire and git gc commands.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!