You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Git拉取报错:bad object refs/desktop.ini,无法删除对应文件

解决Git拉取时fatal: bad object refs/desktop.ini权限问题

步骤1:强制删除.git目录下的desktop.ini文件

受Windows权限限制,普通权限无法删除该文件,需用管理员权限操作:

  1. 右键点击PowerShell,选择「以管理员身份运行」
  2. 切换到你的项目目录:
    cd D:\path\to\your\project
    
  3. 强制删除目标文件:
    Remove-Item -Path .git/refs/desktop.ini -Force
    

若仍提示权限不足,先修改文件权限再删除:

icacls .git/refs/desktop.ini /grant Everyone:F
Remove-Item -Path .git/refs/desktop.ini -Force

步骤2:修复Git引用并重新拉取

删除无效文件后,清理Git的无效引用状态:

git gc --prune=now

之后重新执行拉取命令:

git pull pmo main

步骤3:预防问题再次发生

为避免Google Drive再次生成desktop.ini干扰Git,在项目根目录的.gitignore文件中添加:

desktop.ini

如果没有.gitignore,直接新建一个并写入上述内容即可。

内容的提问来源于stack exchange,提问作者Pinguiz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 13:46:28