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


当前回答

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

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

2) 删除该分支

3) 再次结账。

注意:-您可以隐藏未提交的更改,然后再次将其放回。

其他回答

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

$ 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 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

我用的是git prune的起源,这就完成了工作。

写下可能导致此问题的具体案例。

有一天,我推送了一个名为“feature/subfeature”的分支,同时在远程拥有“feature”分支。

该操作在我这边运行良好,没有任何错误,但当我的同事提取和/或提取任何分支时,他们都收到了完全相同的错误消息:无法更新本地ref,无法锁定ref的refs/remotes/origin/feature/subfeature。

这是通过删除remote上的功能分支(git push--delete origin功能),然后在我同事的repo上运行git remote prune origin来解决的,这会生成包含*[pruned]origin/feature的消息。

所以,我猜git fetch试图在git内部(.git/…)的功能文件夹中创建子功能引用,但创建文件夹失败,因为已经有了功能引用。

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