Git pull无法更新本地引用。

3
自从我们开始使用git子模块以来,我遇到了一些奇怪的问题。我使用Windows 10,并且使用Tortoise git、Powershell、cmd或Linux命令解释器。每当我尝试拉取一个子模块时,就会出现以下类似的情况:
PS
D:\repositories\git\ProjectAlice\ProjectAliceSkills\PublishedSkills\AliceCore>
git pull error: cannot lock ref 'refs/tags/1.0.35>=1.0.0-a4': Unable
to create
'D:/repositories/git/ProjectAlice/ProjectAliceSkills/.git/modules/PublishedSkills/skill_AliceCore/refs/tags/1.0.35>=1.0.0-a4.lock':
Invalid argument From
https://github.com/project-alice-assistant/skill_AliceCore  ! [new
tag]         1.0.35>=1.0.0-a4 -> 1.0.35>=1.0.0-a4  (unable to update
local ref) error: cannot lock ref 'refs/tags/1.0.36>=1.0.0-a5': Unable
to create
'D:/repositories/git/ProjectAlice/ProjectAliceSkills/.git/modules/PublishedSkills/skill_AliceCore/refs/tags/1.0.36>=1.0.0-a5.lock':
Invalid argument  ! [new tag]         1.0.36>=1.0.0-a5 ->
1.0.36>=1.0.0-a5  (unable to update local ref) error: cannot lock ref 'refs/tags/1.0.37>=1.0.0-a5': Unable to create
'D:/repositories/git/ProjectAlice/ProjectAliceSkills/.git/modules/PublishedSkills/skill_AliceCore/refs/tags/1.0.37>=1.0.0-a5.lock':
Invalid argument  ! [new tag]         1.0.37>=1.0.0-a5 ->
1.0.37>=1.0.0-a5  (unable to update local ref) error: cannot lock ref 'refs/tags/1.0.38>=1.0.0-a5': Unable to create
'D:/repositories/git/ProjectAlice/ProjectAliceSkills/.git/modules/PublishedSkills/skill_AliceCore/refs/tags/1.0.38>=1.0.0-a5.lock':
Invalid argument  ! [new tag]         1.0.38>=1.0.0-a5 ->
1.0.38>=1.0.0-a5  (unable to update local ref) error: cannot lock ref 'refs/tags/1.0.39>=1.0.0-a5': Unable to create
'D:/repositories/git/ProjectAlice/ProjectAliceSkills/.git/modules/PublishedSkills/skill_AliceCore/refs/tags/1.0.39>=1.0.0-a5.lock':
Invalid argument  ! [new tag]         1.0.39>=1.0.0-a5 ->
1.0.39>=1.0.0-a5  (unable to update local ref) error: cannot lock ref 'refs/tags/1.0.40>=1.0.0-a5': Unable to create
'D:/repositories/git/ProjectAlice/ProjectAliceSkills/.git/modules/PublishedSkills/skill_AliceCore/refs/tags/1.0.40>=1.0.0-a5.lock':
Invalid argument  ! [new tag]         1.0.40>=1.0.0-a5 ->
1.0.40>=1.0.0-a5  (unable to update local ref) error: cannot lock ref 'refs/tags/1.0.42>=1.0.0-a5': Unable to create
'D:/repositories/git/ProjectAlice/ProjectAliceSkills/.git/modules/PublishedSkills/skill_AliceCore/refs/tags/1.0.42>=1.0.0-a5.lock':
Invalid argument  ! [new tag]         1.0.42>=1.0.0-a5 ->
1.0.42>=1.0.0-a5  (unable to update local ref) PS D:\repositories\git\ProjectAlice\ProjectAliceSkills\PublishedSkills\AliceCore>
git pull error: cannot lock ref 'refs/tags/1.0.35>=1.0.0-a4': Unable
to create
'D:/repositories/git/ProjectAlice/ProjectAliceSkills/.git/modules/PublishedSkills/skill_AliceCore/refs/tags/1.0.35>=1.0.0-a4.lock':
Invalid argument From
https://github.com/project-alice-assistant/skill_AliceCore  ! [new
tag]         1.0.35>=1.0.0-a4 -> 1.0.35>=1.0.0-a4  (unable to update
local ref) error: cannot lock ref 'refs/tags/1.0.36>=1.0.0-a5': Unable
to create
'D:/repositories/git/ProjectAlice/ProjectAliceSkills/.git/modules/PublishedSkills/skill_AliceCore/refs/tags/1.0.36>=1.0.0-a5.lock':
Invalid argument  ! [new tag]         1.0.36>=1.0.0-a5 ->
1.0.36>=1.0.0-a5  (unable to update local ref) error: cannot lock ref 'refs/tags/1.0.37>=1.0.0-a5': Unable to create
'D:/repositories/git/ProjectAlice/ProjectAliceSkills/.git/modules/PublishedSkills/skill_AliceCore/refs/tags/1.0.37>=1.0.0-a5.lock':
Invalid argument  ! [new tag]         1.0.37>=1.0.0-a5 ->
1.0.37>=1.0.0-a5  (unable to update local ref) error: cannot lock ref 'refs/tags/1.0.38>=1.0.0-a5': Unable to create
'D:/repositories/git/ProjectAlice/ProjectAliceSkills/.git/modules/PublishedSkills/skill_AliceCore/refs/tags/1.0.38>=1.0.0-a5.lock':
Invalid argument  ! [new tag]         1.0.38>=1.0.0-a5 ->
1.0.38>=1.0.0-a5  (unable to update local ref) error: cannot lock ref 'refs/tags/1.0.39>=1.0.0-a5': Unable to create
'D:/repositories/git/ProjectAlice/ProjectAliceSkills/.git/modules/PublishedSkills/skill_AliceCore/refs/tags/1.0.39>=1.0.0-a5.lock':
Invalid argument  ! [new tag]         1.0.39>=1.0.0-a5 ->
1.0.39>=1.0.0-a5  (unable to update local ref) error: cannot lock ref 'refs/tags/1.0.40>=1.0.0-a5': Unable to create
'D:/repositories/git/ProjectAlice/ProjectAliceSkills/.git/modules/PublishedSkills/skill_AliceCore/refs/tags/1.0.40>=1.0.0-a5.lock':
Invalid argument  ! [new tag]         1.0.40>=1.0.0-a5 ->
1.0.40>=1.0.0-a5  (unable to update local ref) error: cannot lock ref 'refs/tags/1.0.42>=1.0.0-a5': Unable to create
'D:/repositories/git/ProjectAlice/ProjectAliceSkills/.git/modules/PublishedSkills/skill_AliceCore/refs/tags/1.0.42>=1.0.0-a5.lock':
Invalid argument  ! [new tag]         1.0.42>=1.0.0-a5 ->
1.0.42>=1.0.0-a5  (unable to update local ref)

所以,这与锁定引用有关。让人烦恼的是,当我通过Linux命令解释器进行相同的git pull时,它就能正常工作...... 然而,Tortoise git、cmd或Powershell则会出现上述错误。

我今天确实更新了git,我也尝试了所有在这个问题上找到的修剪建议,但没有解决它。好吧,他们说要使用Linux命令解释器!很遗憾,有大量的子模块....

1个回答

7
问题可能在这里的标签名称:names of the tags
 ! [new tag] 1.0.35>=1.0.0-a4 -> 1.0.35>=1.0.0-a4
这表明在他们的电脑上(毫无疑问运行着Linux),他们有一个名为1.0.35>=1.0.0-a4的Git标签。你的Git,在你的电脑上运行,决定创建同名的标签。(这就是标签的基本概念:与分支名称不同,每个人都应该共享相同的名称。因此,如果他们在他们的Git中创建了一个标签X,你的Git将复制该标签及其存储的哈希ID到你的Git中,同时也称之为X。与分支名称相比:如果他们创建了一个名为X分支,你的Git将重命名它并将其称为origin/X。)
为此,您的Git正在尝试创建带有此字符串作为文件名一部分的本地文件系统文件。由于某种原因,您的计算机拒绝这样做,可能是拒绝了>字符。请参见Bret Cameron的答案Windows和Linux目录名称中禁止使用哪些字符?
解决此问题的方法之一是告诉您的Git根本不要尝试复制他们的标签:将--no-tags添加到您的git fetchgit pull命令中。更好的解决方案是让您的同事/同事停止在任何名称中使用这样的字符。

是的,你是正确的,非常感谢你提醒我!我用一个小脚本重写了每个子模块上的所有标签。 - Psychokiller1888
如果在新分支上发生这种情况怎么办?我得到了 ! [new branch] user/con -> origin/user/con (unable to update local ref) 的错误,因为在Windows上不允许使用con作为文件名。有没有任何标志可以克服这个问题? - Shlomo Gottlieb
1
@ShlomoGottlieb:不需要,只需更改分支名称即可。(除了人类偏好/理智外,在任何两个存储库中都没有必要使用相同的分支名称。在这种情况下,Windows 强制执行疯狂。)由于它们具有 con 名称,您根本无法创建 origin/user/con 名称,因此您将不得不执行 git fetch origin user/con:refs/remotes/origin/user-con 或类似的操作,这将很麻烦,但可以解决问题。 - torek
1
为了恢复正常,请要求他们更改其分支名称。同时,考虑将此项设置为单分支克隆,或以其他方式调整默认的获取参考规范。 - torek

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接