git pull失败“无法解决参考”“无法更新本地参考”

使用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 remote prune origin ,但它没有帮助。

尝试清理您的本地存储库:

 $ 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-remote(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>". 

也发生在我身上。 在我的情况下,坏的参考是主人,我做了以下:

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

这使得git恢复了ref文件。 之后,一切都如预期再次运作。

这为我做了这份工作:

 git gc --prune=now 

对我来说,它的工作,以消除文件夹中的错误的文件

git的/参/遥控器/产地/

我有这个相同的问题,并通过去它错误的文件解决了它:

 \repo\.git\refs\remotes\origin\master 

这个文件充满了空值,我用github最新的refreplace了它。

这适用于我:

 git gc --prune=now 

在SourceTree上需要更多的解决方法。

在我的情况下,我删除了.git下的所有删除参考文件后,问题就解决了

如果你看看这个消息,它会告诉你哪些文件需要删除(特别是)

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

我刚刚删除了所有的文件,并运行gc修剪

 git gc --prune=now 

之后,一切正常。

它适用于我这两个命令行
我有错误的ref问题,我不能做拉

 $ git gc --prune=now $ git remote prune origin 

执行以下命令:

 rm .git/refs/remotes/origin/master git fetch git branch --set-upstream-to=origin/master 

要在很短的时间内回答这个问题,当你的本地有一些关于远程的信息时,这个问题就会出现,而有人会改变一些使远程的和你的改变不同步的东西

我得到这个问题,因为有人删除远程分支,并再次创build相同的名称。

为了处理这些问题,请从远程执行拖拉操作。

 git remote prune origin 

或者如果您正在使用任何GUI,请从远程进行抓取。

在这里输入图像说明

如果git gc --prune=now帮你。 (像我这样的坏运气)

我所做的是在本地删除项目,并再次克隆整个项目。

我能够工作

 git remote update --prune 

我有同样的问题。 我遵循以下步骤

1)将有问题的分支切换到其他分支

2)删除该分支

3)再次结帐。

注意: – 您可以隐藏未提交的更改并重新放回。

对我来说,我有一个名为feature/phase2的本地分支,远程分支名为feature/phase2/data-model 。 命名冲突是问题的原因,所以我删除了我的本地分支(如果需要保留的话,可以重命名它)

我有与composer php更新相同的问题。 但是对于我来说,只有在我清除了作曲者caching并删除了供应商文件夹的内容之后,

 rm -rf vendor/* git gc --prune=now git pull composer clear-cache composer update my/package 

当试图克隆一个git bundle创build的文件时,得到了这个问题,没有其他的答案工作,因为我无法克隆回购(所以git gc和删除/编辑文件是不可能的)。

但有另一种方法来解决这个问题 – 一个.bundle文件的源文件正在开始:

 # v2 git bundle 9a3184e2f983ba13cc7f40a820df8dd8cf20b54d HEAD 9a3184e2f983ba13cc7f40a820df8dd8cf20b54d refs/heads/master 9a3184e2f983ba13cc7f40a820df8dd8cf20b54d refs/heads/master PACK.......p..x...Kj.0...: (and so on...) 

简单地用vim删除第四行解决了这个问题。

我在使用SourceTree时遇到了这个问题。 我试图再拉,它的工作。 我想我是疯狂的分支(结帐)太快:)。

我的情况与海报有些不同,因为我的存储库相对合作,没有任何明显的腐败。

有相同的味精,但有一个目录,得到一个失败的味精拉。

git –prone也帮不了我。 原来有一个与远程创build的目录名称相同的文件。

必须去.git \ logs \ refs \ remotes \ origin并擦除语言环境文件 – 然后再次拉动,一切正常。

尝试这个:

 git pull origin Branch_Name 

Branch_Name ,你当前Branch_Name的分支。

如果你只做一个git pull ,它也会把所有其他创build的分支名称也拉出来。

所以你得到这个的原因是:

 ! [new branch] split-css -> origin/split-css (unable to update local ref) 
  # remove the reference file of the branch "lost" rm -fv ./.git/refs/remotes/origin/feature/v1.6.9-api-token-bot-reader # get all the branches from the master git fetch --all # git will "know" how-to handle the issue from now on # From github.com:futurice/senzoit-www-server # * [new branch] feature/v1.6.9-api-token-bot-reader -> # origin/feature/v1.6.9-api-token-bot-reader # and push your local changes git push 

刚才遇到了这个问题。

使用Windows服务器上的SourceTree,您可能需要以pipe理员身份运行它。 这解决了我的问题“无法更新本地参考”Atlassian源树2.1.2.5在Windows Server 2012 R2的域中。

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 

不过,这是假定有问题的分支已经被删除了。

一旦运行git fetch,我得到这个错误:

错误:无法lockingref'refs / remotes / origin / branchname':ref refs / remotes / origin / featureEmailTemplate is at 45c5f2ab … but expected d48af9 … from https://…/ …(unable to更新本地参考)

下面的命令解决了这个问题:

git gc –prun = now