使用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捆绑包创建的文件中克隆时遇到此问题,其他答案都无效,因为我无法克隆repo(因此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删除第四行就解决了这个问题。

其他回答

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

$ 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 remote prune origin

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

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

执行以下命令:

rm .git/refs/remotes/origin/master

git fetch

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

以防万一,如果你需要知道什么是.git/refs/remotes/origin/master,您将阅读remotes部分在Git参考中。

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

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

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

没有当前分支的跟踪信息

所以接下来我做的是:

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