git pull fails “unable to resolve reference” “unable to update local ref”

简介: 问题由于有人rebase了分支,或者不知道怎么搞的。其他人拉取代码的时候,发现拉不下来。>git fetcherror: cannot lock ref 'refs/remotes/origin/xxx-branch': is at 8117caf7b1c88b2d5dfebd7581f68...

问题

由于有人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





唯有不断学习方能改变! -- Ryan Miao
目录
相关文章
|
2月前
|
开发工具 git 开发者
|
2月前
|
开发工具 git 开发者
Git Pull vs. Git Fetch:深度解析
【2月更文挑战第29天】
150 0
Git Pull vs. Git Fetch:深度解析
|
缓存 开发工具 git
【已解决】git pull 显示 Already up-to-date,但文件并没有更新
git pull 显示 Already up-to-date,但文件并没有更新
1267 0
|
开发工具 git
Git详解——pull、push、clone、fork、pull request图解及命令速查
本文主要针对Git中pull、push、clone、fork、pull request图解及命令详解
344 0
Git详解——pull、push、clone、fork、pull request图解及命令速查
|
4月前
|
存储 网络安全 数据处理
git远程操作,推送【push】,拉取【pull】,忽略特殊文件,配置别名,标签管理
git远程操作,推送【push】,拉取【pull】,忽略特殊文件,配置别名,标签管理
|
Linux 网络安全 开发工具
Linux 安装git,并且使用https方式 git pull 代码的免密操作
Linux 安装git,并且使用https方式 git pull 代码的免密操作
319 0
|
12月前
|
数据可视化 开发工具 Android开发
Android Git 拉取代码报错:error: cannot pull with rebase: Your index contains uncommitted changes.
造成原因:在使用Android Studio中Git的Commit Directory 将本地更改的代码保存到本地后,点击commit,发现提交不上去,发现本地有代码,这时候拉取代码,报错:cannot pull with rebase: Your index contains uncommitted changes.表示我的索引有未提交的改变
|
网络安全 开发工具 git
GIt远程仓库pull拉取代码
GIt远程仓库pull拉取代码
367 0
|
开发工具 git
Git Pull Failed 解决办法
Git Pull Failed 解决办法
Git Pull Failed 解决办法
|
开发工具 git
git回退版本,再返回最新分支git pull失败的解决经验
git回退版本,再返回最新分支git pull失败的解决经验
192 1
git回退版本,再返回最新分支git pull失败的解决经验

相关实验场景

更多