使用git 1.6.4.2时,当我尝试git pull时,会出现以下错误:

error: unable to resolve reference refs/remotes/origin/LT558-optimize-sql: No such file or directory
From git+ssh://remoteserver/~/misk5
 ! [new branch]      LT558-optimize-sql -> origin/LT558-optimize-sql  (unable to update local ref)
error: unable to resolve reference refs/remotes/origin/split-css: No such file or directory
 ! [new branch]      split-css  -> origin/split-css  (unable to update local ref)

我尝试过git远程梅干起源,但没用。


当前回答

当Mac上的一个开发人员创建了一个分支,分支名称中带有大于“>”符号时,我们遇到了这个问题。

这在TeamCity和运行SourceTree的基于Windows的本地计算机上造成了问题。BitBucket让它顺利通过。

为了解决这个问题,用户删除了分支并重新创建了它。这很简单。

其他回答

解释:您的远程repo(在GitHub/BitBucket中)分支似乎已被删除,尽管您的本地引用未被更新并指向不存在的引用。

为了解决这个问题:

git fetch --prune
git fetch --all
git pull

额外阅读-参考Git文档:

gitfetch-从另一个存储库下载对象和引用--全部取下所有遥控器。--修剪提取后,删除远程上不再存在的任何远程跟踪分支。

当存储库被删除并以相同的名称创建时,也面临同样的问题。它只在我重新设置远程url时起作用,如下所示;

git远程设置url来源[git_REPO_url]

验证远程url:

git remote -v

现在,所有命令都应该照常工作。

如果有人觉得这很有用,我会长期遇到这个问题,虽然不是经常出现,因为我在Dropbox中有git目录,从Dropbox中删除了它,一切都很好。

尝试使用以下方法清理本地存储库:

$ 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=<date> | --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远程(1):

git-remote - manage set of tracked repositories

git remote prune [-n | --dry-run] <name>

           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>".            

在我的例子中,在删除了.git目录下的所有删除引用文件之后,问题就解决了。

如果您查看消息,它会告诉您需要删除哪些文件(特别是)。

要删除的文件位于.git/refs/remotes下。

我刚刚删除了那里的所有文件,并运行了gc prune

git gc --prune=now

之后,一切正常。