救命!当我尝试git push origin master现在做时,我得到:
fatal: Unable to create '/home/ubuntu/workspace/.git/refs/remotes/origin/master.lock': File exists.
If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.
Run Code Online (Sandbox Code Playgroud)
当然,我还发现了其他类似的问题(例如here),但是那里被高调回答的问题只是建议删除有问题的文件...但是该文件不存在!
我担心这是在我最近尝试使用以下方法清除一些空间之后发生的:
$ sudo git reflog expire --all --expire=now
$ sudo git gc --prune=now --aggressive
Run Code Online (Sandbox Code Playgroud)
那可能是原因吗?有修复建议吗?
该问题似乎源于以超级用户(sudo ...)运行到期代码。当Git调整了远程跟踪分支文件时,它们就由超级用户拥有(因此只能由超级用户调整)。
解决方法是将这些文件放回正确的所有者(在这种情况下为ubuntu)。一个人可以使用一揽子所有权更改(例如)sudo chown -R ubuntu .git,或选择性地(仅更改错误拥有的文件)(例如,以root身份使用)(或者sudo再次,由于管道的原因,这有点烦人)find .git -user root -print0 | xargs -0 chown ubuntu。它们之间的唯一区别(如果有的话)将是chown -R可能更新更多文件的ctime(inode更改时间)字段(通过chown在已正确拥有的文件上实际运行系统调用),这又会影响备份系统。
更为通用的规则是“不要sudo在材质前加上任意前缀”,在这种情况下,没有理由sudo在git reflog expireand git gc命令前放置内容。
| 归档时间: |
|
| 查看次数: |
1620 次 |
| 最近记录: |