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
目录
相关文章
|
开发工具 git
git fetch和 pull的区别
`git fetch`和 `git pull`在Git中扮演着不同的角色,了解它们的区别和使用场景对于高效管理代码库至关重要。通过合理使用这两个命令,可以更好地控制代码合并过程,减少冲突,提高团队协作效率。
1159 97
|
开发工具 git Python
通过Python脚本git pull 自动重试拉取代码
通过Python脚本git pull 自动重试拉取代码
578 5
|
11月前
|
网络协议 开发工具 git
解决 git 报错 “fatal: unable to access ‘https://github.com/.../.git‘: Recv failure Connection was rese
在使用 Git/Git小乌龟 进行代码管理的过程中,经常会遇到各种各样的问题,其中之一就是在执行 git clone 或 git pull 等操作时出现 “fatal: unable to access ‘https://github.com/…/.git’: Recv failure Connection was reset” 的报错。这个问题通常是由网络连接问题或代理设置不正确导致的。在我的个人使用经验中,我亲自尝试了四种方法,它们都能够有效地解决这个报错。个人比较推荐方法二。
8251 1
|
开发工具 git
git fetch和 pull的区别
通过这些内容和示例,您可以系统地理解 `git fetch`和 `git pull`的区别,并在实际工作中灵活应用这两个命令,提高版本控制的效率。希望这些内容对您的学习和工作有所帮助。
1053 24
|
安全 开发工具 git
git分布式版本控制系统及在码云上创建项目并pull和push
通过本文的介绍,我们详细讲解了Git的基本概念和工作流程,并展示了如何在码云上创建项目及进行pull和push操作。Git作为一种分布式版本控制系统,为开发者提供了强大的工具来管理代码变更和协作开发。希望本文能帮助您更好地理解和使用Git及码云,提高开发效率和代码质量。
713 18
|
安全 开发工具 git
git分布式版本控制系统及在码云上创建项目并pull和push
通过本文的介绍,我们详细讲解了Git的基本概念和工作流程,并展示了如何在码云上创建项目及进行pull和push操作。Git作为一种分布式版本控制系统,为开发者提供了强大的工具来管理代码变更和协作开发。希望本文能帮助您更好地理解和使用Git及码云,提高开发效率和代码质量。
464 16
|
开发工具 git 开发者
Git Fetch 和 Git Pull:理解两者的区别
【8月更文挑战第27天】
1604 1
|
开发工具 git
unable to index file ‘~$git提交版本号.xlsx‘
unable to index file ‘~$git提交版本号.xlsx‘
|
开发工具 git
深入理解Git中的git pull和git fetch命令
深入理解Git中的git pull和git fetch命令
990 0
|
Shell 网络安全 开发工具
fatal: unable to access 'https://github.com/wolfcw/libfaketime.git/': Encountered end of file
fatal: unable to access 'https://github.com/wolfcw/libfaketime.git/': Encountered end of file