git pull fails “unable to resolve reference” “unable to update local ref”
问题
由于有人rebase了分支,或者不知道怎么搞的。其他人拉取代码的时候,发现拉不下来。
>git fetch
error: cannot lock ref 'refs/remotes/origin/xxx-branch': is at 8117caf7b1c88b2d5dfebd7581f6891d87b9abee but expected f38e8d35ae8ea7f177c537a98f4140dd76b8e2bd
From xxxxxxx-git-url
! f38e8d35..9d7b8e7a xxx-branch -> origin/xxx-branch (unable to update local ref)
解决方案
尝试clean本地git
$ git gc --prune=now
$ git remote prune origin
man git-gc(1):
git-gc - Cleanup unnecessary files and optimize the local repository
git gc [--aggressive] [--auto] [--quiet] [--prune=
| --no-prune]
Runs a number of housekeeping tasks within the current >repository, such as compressing file revisions (to reduce disk space and increase performance) and removing unreachable objects which may have been created from prior invocations of git add. Users are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good operating performance.
man git-remote(1):
git-remote - manage set of tracked repositories
git remote prune [-n | --dry-run]
Deletes all stale remote-tracking branches under <name>. These stale branches have already been removed from the remote repository referenced by <name>, but are still locally available in "remotes/<name>".
来源
Stack Overflow ,
原问题:https://stackoverflow.com/questions/2998832/git-pull-fails-unable-to-resolve-reference-unable-to-update-local-ref
关注我的公众号

分类:
版本控制(git等)
标签:
Git
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了