使用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)
Run Code Online (Sandbox Code Playgroud)
我试过git remote prune origin,但没有用.
Voj*_*tek 860
尝试使用以下方法清理本地存储库:
$ git gc --prune=now
$ git remote prune origin
Run Code Online (Sandbox Code Playgroud)
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.
Run Code Online (Sandbox Code Playgroud)
男人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>".
Run Code Online (Sandbox Code Playgroud)
Mic*_*mer 554
也发生在我身上.在我的情况下,坏参考是主人,我做了以下:
rm .git/refs/remotes/origin/master
git fetch
Run Code Online (Sandbox Code Playgroud)
这使得git恢复了ref文件.之后,一切都按预期工作了.
小智 124
这对我有用:
git gc --prune=now
Run Code Online (Sandbox Code Playgroud)
Bri*_*jen 73
对我来说,它可以删除从文件夹中抛出错误的文件.git/refs/remotes/origin/.
avi*_*amg 51
说明:看来您的远程仓库(在 Github/bitbucket 中)分支已被删除,尽管您的本地引用未更新并指向不存在的引用。
为了解决这个问题:
git fetch --prune
git fetch --all
git pull
Run Code Online (Sandbox Code Playgroud)
额外阅读 - Github 文档中的参考:
git-fetch - 从另一个存储库下载对象和引用
--all 获取所有遥控器。
--prune 获取后,删除远程上不再存在的任何远程跟踪分支。
小智 48
试试吧:
git gc --prune=now
git remote prune origin
git pull
Run Code Online (Sandbox Code Playgroud)
Mat*_*iao 43
执行以下命令:
rm .git/refs/remotes/origin/master
git fetch
git branch --set-upstream-to=origin/master
Run Code Online (Sandbox Code Playgroud)
以防万一,如果你需要知道是什么
.git/refs/remotes/origin/master,你会阅读Git References中的Remotes部分.
Noe*_*ock 38
我有同样的问题,并通过转到它错误的文件解决了它:
\repo\.git\refs\remotes\origin\master
Run Code Online (Sandbox Code Playgroud)
这个文件充满了空,我用github的最新ref替换了它.
Uri*_*and 38
在我的情况下,我删除了目录下的所有删除引用文件后,问题得以解决.git.
如果您查看该消息,它会告诉您需要删除哪些文件(具体而言).
要删除的文件位于.git/refs/remotes.
我刚刚删除了那里的所有文件,并运行了gc prune
git gc --prune=now
Run Code Online (Sandbox Code Playgroud)
在那之后,一切正常.
Daw*_*žan 38
我只想补充引用中断的可能性.
在我的系统(Windows 7 64位)上,当发生BSOD时,一些存储的参考文件(最有可能当前在BSOD发生时打开/写入)被NULL字符(ASCII 0)覆盖.
正如其他人所提到的,要修复它,只需删除那些无效的参考文件并重新获取或重新拉取存储库即可.
错误: cannot lock ref 'refs/remotes/origin/some/branch': unable to resolve reference 'refs/remotes/origin/some/branch': reference broken
解决方案:删除文件%repo_root%/.git/refs/remotes/origin/some/branch
Iny*_*oka 21
如果此错误“无法更新本地引用”再次出现,即使在应用了Vojtech Vitek或Michel Krämer的答案后,您的本地 AND 主存储库也可能有错误的引用。
在这种情况下,您应该同时应用两个修复程序,而不要在两者之间拉动或推动......
rm .git/refs/remotes/origin/master
git fetch
git gc --prune=now
git remote prune origin
Run Code Online (Sandbox Code Playgroud)
对我来说,只有在推/拉之前应用了两个修复程序后才能实现永久解决方案。
mar*_*ych 17
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
Run Code Online (Sandbox Code Playgroud)
这假设在遥控器上删除了违规分支.
小智 11
对我来说,我是这样解决的:
rm .git/refs/remotes/origin/master
git fetch
Run Code Online (Sandbox Code Playgroud)
之后,我从 github 收到此消息。
当前分支没有跟踪信息
所以接下来我解决这个问题的是:
git branch --set-upstream-to=origin/master master
git pull
Run Code Online (Sandbox Code Playgroud)
要在非常短的时间内解决这个问题,当您的本地有一些关于遥控器的信息并且有人更改使远程和您的更改不同步的某些内容时,会出现此问题.
我收到此问题是因为有人删除了远程分支并再次创建了相同的名称.
要处理此类问题,请从远程执行pull或fetch.
git remote prune origin
Run Code Online (Sandbox Code Playgroud)
或者如果您正在使用任何GUI,请从远程执行提取.
错误:无法锁定引用”仅仅意味着 /refs 中的信息已损坏,Git 无法继续创建 index.lock 文件。
快速修复:删除并重新添加遥控器。
1-复制现有远程的 SSH git URL。您可以使用以下命令将其打印到终端:
git remote -v
2- 从本地 git 存储库中删除遥控器:
git remote rm origin
3-将遥控器添加回本地存储库:
git remote add origin git@server-address.org:your-username/repo-name.git
4- 修剪远程源在线论坛上的用户报告说以下命令对他们有效:
git remote prune origin
5-清理和优化本地存储库
git gc --prune=now
您可以在本文中找到更多信息: https://linuxpip.org/git-error-cannot-lock-ref/
$ rm .git/refs/remotes/origin/master
$ git fetch
Run Code Online (Sandbox Code Playgroud)
从bitbucket.org:xx/mkyong-tutorials
df0eee8..3f7af90 master -> origin/master
$ git pull
Run Code Online (Sandbox Code Playgroud)
已经是最新的了。
小智 5
尝试这个:
git pull origin Branch_Name
Run Code Online (Sandbox Code Playgroud)
Branch_Name,您当前所在的分支。
如果你只做 a git pull,它也会拉取所有其他创建的分支名称。
这就是你得到这个的原因:
! [new branch] split-css -> origin/split-css (unable to update local ref)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
344539 次 |
| 最近记录: |