libgit2返回:在TortoiseGit中找不到refspec'refs / heads / origin / HEAD'错误 [英] libgit2 returned: Refspec 'refs/heads/origin/HEAD' not found error in TortoiseGit

查看:2710
本文介绍了libgit2返回:在TortoiseGit中找不到refspec'refs / heads / origin / HEAD'错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在启动TortoiseGit时遇到这个错误:


无法获取所有文件


libgit2文件返回:Refspec'refs / heads /原产地/ HEAD'找不到

虽然令人讨厌,但它并不妨碍我使用TortoiseGit。不过,我想让它消失,因为它很好,烦人。如何解决这个问题? 事实证明,为了更新分支< remote> / HEAD 点的 本地回购视图到,你可以让git自动从远程获取这些信息并在本地为你设置,而不是像我的旧解决方案那样用 git symbolic-ref 手动设置它。上面:

  git remote set-head< remote> --auto 

#或更短
git远程设置头<远程> -a

请注意,此命令 实际上并未更改默认分支是在远程回购本身 。为此,您可能需要如果您有权访问它,请直接在远程仓库上使用 git symbolic-ref





旧回覆



错误消息引用的问题是显然libgit2正在尝试读取由 refs / remotes / origin / HEAD 指向的远程默认分支,但远程分支不会'
$ b

使用 git branch -a ,我的本地仓库认为 origin / develop 是远程默认分支:

 遥控器/ origin / HEAD  - > ; origin / develop 

一点 origin / develop 确实是我在GitHub上的 origin repo中的默认分支,但它已经不再是了, master 分支是。 开发分支已从 origin 中删除​​,因为它已不再需要。



所以我通过手动更新本地引用 origin / HEAD 指向 origin $ b $ pre $ git symbolic-ref refs / remotes / origin / HEAD refs / remotes / origin / master

或者,如果我还想为 refs / remotes / origin / HEAD

git symbolic-ref -mUpdate to new远程默认分支\
refs / remotes / origin / HEAD refs / remotes / origin / master

这解决了这个问题。另见:


  1. git symbolic-ref 的文档。

  2. Git:正确的方式来更改裸仓库中的活动分支?

  3. #1485590#1485590>如何更改Git远程头指向除master之外的其他内容


I got this error when starting up TortoiseGit:

Could not get all refs.
libgit2 returned: Refspec 'refs/heads/origin/HEAD' not found

While annoying, it does not prevent me from using TortoiseGit. However, I'd like to make it go away, because it is, well, annoying. How do I fix this?

解决方案

Updated Answer

So it turns out that, for the purpose of updating a local repo's view of which branch <remote>/HEAD points to, you can have git automatically fetch that information from the remote and set it locally for you, instead of having to manually set it with git symbolic-ref like in my old solution above:

git remote set-head <remote> --auto

# Or shorter
git remote set-head <remote> -a

Note that this command doesn't actually change what the default branch is on the remote repo itself. For that, you'll probably need to use git symbolic-ref directly on the remote repo, if you have access to it.

Old Answer

The problem that the error message refers to is that apparently libgit2 is trying to read the remote default branch pointed to by refs/remotes/origin/HEAD, but the remote branch doesn't exist, thus the error.

Using git branch -a, my local repo thinks that origin/develop is the remote default branch:

remotes/origin/HEAD -> origin/develop

At one point origin/develop was indeed the default branch in my origin repo on GitHub, but it isn't any longer, the master branch is. The develop branch was deleted from origin since it was no longer needed.

So I fixed this by manually updating the local reference origin/HEAD to point to the new default branch on origin:

git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/master

Or if I wanted to also add a message to the reflog for refs/remotes/origin/HEAD:

git symbolic-ref -m "Update to new remote default branch" \
refs/remotes/origin/HEAD refs/remotes/origin/master

This resolved the issue. See also:

  1. Documentation for git symbolic-ref.
  2. Git: Correct way to change Active Branch in a bare repository?.
  3. How do I change a Git remote HEAD to point to something besides "master".

这篇关于libgit2返回:在TortoiseGit中找不到refspec'refs / heads / origin / HEAD'错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆