使用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远程梅干起源,但没用。


当前回答

对我来说,它可以从.git/refs/remotes/origin/文件夹中删除引发错误的文件。

其他回答

由Google Drive desktop.ini文件引起时

用于Windows的Google Drive客户端在每个文件夹中创建desktop.ini文件。如果您的git存储库位于正在与Google Drive同步的目录中,则desktop.ini文件将导致git存储失败,出现以下情况:

cannot lock ref 'refs/remotes/origin/desktop.ini': unable to resolve reference 'refs/remotes/origin/desktop.ini': reference broken

要解决此错误,您可能需要删除git存储库中的desktop.ini文件。

如果安装了WSL,则可以使用以下命令删除desktop.ini文件:

注:⚠️ 此命令将删除<project_directory>中所有.git目录中的所有desktop.ini文件。

find <project_directory> -type d -name .git -print0 | xargs -0 -I {} find {} -type f -name desktop.ini -print0 | xargs -0 -I {} rm -vf {}

如果只想删除特定.git目录中的desktop.ini文件,则可以使用以下命令:

find <.git_directory> -type f -name desktop.ini -print0 | xargs -0 -I {} rm -vf {}

git fetch--prune为我修复了这个错误:

[marc.zych@marc-desktop] - [~/code/driving] - [Wed May 10, 02:58:25]
[I]> git fetch
error: cannot lock ref 'refs/remotes/origin/user/janek/integration/20170505': 'refs/remotes/origin/user/janek/integration' exists; cannot create 'refs/remotes/origin/user/janek/integration/20170505'
From github.com:zooxco/driving
 ! [new branch]            user/janek/integration/20170505 -> origin/user/janek/integration/20170505  (unable to update local ref)
From github.com:zooxco/driving
[marc.zych@marc-desktop] - [~/code/driving] - [Wed May 10, 02:58:30]
[I]> git fetch --prune
 - [deleted]               (none)     -> origin/user/janek/integration

不过,这假设有问题的分支已在远程删除。

您也可以将其添加到~/.gitconfig中,以在运行git fetch时自动修剪:

[fetch]
    prune = true

我正在使用Tower,不知为什么,我的文件夹名是.git/refs/remotes/origin/Github。将其更改为小写的.git/refs/remotes/origin/github解决了这个问题。

$ rm .git/refs/remotes/origin/master

$ git fetch

来自bitbucket.org:xx/mkyong教程

df0eee8..3f7af90  master     -> origin/master

$ git pull

已经是最新的。

对我来说,我是这样解决的:

rm .git/refs/remotes/origin/master
git fetch

之后,我从github收到了这条消息。

没有当前分支的跟踪信息

所以接下来我做的是:

git branch --set-upstream-to=origin/master master
git pull