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

其他回答

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

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

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

错误:无法锁定ref”仅仅意味着/refs中的信息已损坏,Git无法继续创建index.lock文件。

快速修复:删除并重新添加远程。

1-复制现有远程设备的SSH git URL。您可以使用以下命令将其打印到终端:

git远程-v

2-从本地git repo中删除远程设备:

git远程rm源

3-将远程设备添加回本地存储库:

git远程添加原点git@server-address.org:您的用户名/rep-name.git

4-修剪远程原点在线论坛的用户报告说,下面的命令对他们有效:

git远程修剪原点

5-清理和优化本地存储库git-gc--prune=现在

您可以在本文中找到更多信息:https://linuxpip.org/git-error-cannot-lock-ref/

试试看:

git pull origin Branch_Name

Branch_Name,您当前所在的分支。

如果您只执行一个git pull,它也会提取所有其他创建的分支名称。

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

! [new branch]      split-css  -> origin/split-css  (unable to update local ref)

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

$ 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 gc --prune=now