git pull error: remote ref is at but expected

来源:互联网 发布:2015酒店行业数据 编辑:程序博客网 时间:2024/05/23 20:02

Analysis

If you are running git under a file system that is not case sensitive (Windows or OS X) this will occur if there are two branches with the same name but different capitalisation

Solution

A

  1. Delete the wrong remote branch (you shouldn’t have branches that differ only by case)
git push origin -- delete branch-name
  1. and then
git remote prune origin 

and everything should work

B

  1. 查看引用
git show-ref |grep branch-name
  1. 删除本地 ref (对远端不会有影响)
git update-ref -d refs/remotes/origin/branch-name

  • 查看分支详情
    git log –source |grep branch-name

  • Git 清理无效的远程追踪分支

    1. 查看信息
      git branch –a 用来查看所有的分支,包括本地和远程的。
      分支在远程其实早就被删除了,但是在本地依然可以看见。

    查看有关于origin的一些信息,包括分支是否tracking。
    git remote show origin

    远程版本库上删除了某一分支,假如远程版本库名是 origin,则使用如下命令先查看哪些分支需要清理:
    git remote prune origin –dry-run

    1. 然后执行
      git remote prune origin
      刷新本地仓库与远程仓库的保持这些改动的同步,完成了无效的远程追踪分支的清理工作。

    无效的远程追踪分支会以gone来标识

Reference

  • https://stackoverflow.com/questions/11796580/git-pull-error-error-remote-ref-is-at-but-expected
  • https://git-scm.com/book/zh/v2/Git-%E5%86%85%E9%83%A8%E5%8E%9F%E7%90%86-Git-%E5%BC%95%E7%94%A8
  • https://git-scm.com/book/zh/v2/Git-%E5%86%85%E9%83%A8%E5%8E%9F%E7%90%86-%E5%BC%95%E7%94%A8%E8%A7%84%E6%A0%BC
阅读全文
0 0
原创粉丝点击