当通过 --tags 获取 git refs 时,"upload-pack: not our ref"是什么意思?



在我的一个项目中,Travis构建在我的任何构建系统或代码到达之前就失败了,只要我的构建脚本尝试用git fetch --tags:获取所有Git标记

`` git fetch --tags --verbose
POST git-upload-pack (350 bytes)
POST git-upload-pack (788 bytes)
POST git-upload-pack (797 bytes)
From https://github.com/ELLIOTTCABLE/bs-sedlex
= [up to date]      fix-ci        -> origin/fix-ci
* [new tag]         sedlex-1.99.2 -> sedlex-1.99.2
* [new tag]         v1.99.3       -> v1.99.3
...
* [new tag]         v20.0.0-pre.2 -> v20.0.0-pre.2
Fetching submodule ppx-sedlex
POST git-upload-pack (122 bytes)
From https://github.com/ELLIOTTCABLE/ppx-sedlex
= [up to date]      develop       -> origin/develop
= [up to date]      master        -> origin/master
...
= [up to date]      v20.0.0-pre.2 -> v20.0.0-pre.2
POST git-upload-pack (4 bytes)
POST git-upload-pack (69 bytes)
POST git-upload-pack (586 bytes)
fatal: remote error: upload-pack: not our ref 0f509703fcd43ff4324d721a39220153bab49d4a

这尤其令人困惑,因为无论是主回购bs-sedlex还是git子模块ppx-sedlex,都没有像0f5097...那样的提交启动;我不知道那个SHA是从哪里来的。这个故障只发生在Linux工作程序上,我不明白为什么——同一个repo上的git fetch --tags在macOS Travis工作程序上、在我的macOS机器上以及在我为调试它而开发的Ubuntu Vagrant盒子上都有效。

"致命:远程错误:上传包:不是我们的参考"错误意味着什么;我该如何解决它?我甚至不知道从哪里开始调试这个错误,因为它只发生在Travis员工身上。

(这不太可能有帮助,但这是上下文中的错误,以及有问题的存储库。)

编辑1:以下是添加GIT_TRACE=2:的一些额外有趣的输出

Fetching submodule ppx-sedlex
23:55:28.125076 git.c:439               trace: built-in: git fetch --no-prune --no-prune-tags --tags -v --recurse-submodules-default on-demand --submodule-prefix ppx-sedlex/
23:55:28.125914 run-command.c:663       trace: run_command: git-remote-https origin https://github.com/ELLIOTTCABLE/ppx-sedlex.git
23:55:28.429609 run-command.c:663       trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs
23:55:28.432485 run-command.c:663       trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs
23:55:28.434082 git.c:439               trace: built-in: git rev-list --objects --stdin --not --all --quiet --alternate-refs
From https://github.com/ELLIOTTCABLE/ppx-sedlex
= [up to date]      develop       -> origin/develop
= [up to date]      master        -> origin/master
= [up to date]      v1.99.4       -> v1.99.4
= [up to date]      v1.99.4-pre.1 -> v1.99.4-pre.1
= [up to date]      v1.99.4-pre.3 -> v1.99.4-pre.3
= [up to date]      v1.99.4-pre.8 -> v1.99.4-pre.8
= [up to date]      v2.0.0        -> v2.0.0
= [up to date]      v20.0.0-pre.1 -> v20.0.0-pre.1
= [up to date]      v20.0.0-pre.2 -> v20.0.0-pre.2
23:55:28.442482 run-command.c:1616      run_processes_parallel: preparing to run up to 1 tasks
23:55:28.442504 run-command.c:1648      run_processes_parallel: done
23:55:28.442536 run-command.c:663       trace: run_command: git gc --auto
23:55:28.443983 git.c:439               trace: built-in: git gc --auto
23:55:28.444903 run-command.c:663       trace: run_command: cd /home/vagrant/ELLIOTTCABLE/bs-sedlex/.git/modules/ppx-sedlex; unset GIT_PREFIX; GIT_DIR=. git fetch --no-prune --no-prune-tags --tags -v --recurse-submodules-default on-demand --submodule-prefix ppx-sedlex/ origin 0f509703fcd43ff4324d721a39220153bab49d4a
23:55:28.446392 git.c:439               trace: built-in: git fetch --no-prune --no-prune-tags --tags -v --recurse-submodules-default on-demand --submodule-prefix ppx-sedlex/ origin 0f509703fcd43ff4324d721a39220153bab49d4a
23:55:28.447105 run-command.c:663       trace: run_command: git-remote-https origin https://github.com/ELLIOTTCABLE/ppx-sedlex.git
23:55:28.735871 run-command.c:663       trace: run_command: git fetch-pack --stateless-rpc --stdin --lock-pack --thin --no-progress https://github.com/ELLIOTTCABLE/ppx-sedlex.git/
23:55:28.738885 git.c:439               trace: built-in: git fetch-pack --stateless-rpc --stdin --lock-pack --thin --no-progress https://github.com/ELLIOTTCABLE/ppx-sedlex.git/
error: Server does not allow request for unadvertised object 0f509703fcd43ff4324d721a39220153bab49d4a

我无法掩饰Git为什么在这里请求"未发布对象";但这显然不是GitHub的问题,这里——出于某种原因,命令:

git fetch --no-prune --no-prune-tags --tags -v 
--recurse-submodules-default on-demand  
--submodule-prefix ppx-sedlex/ 
origin 0f509703fcd43ff4324d721a39220153bab49d4a

当Igit fetch在父repo中时,正在子模块上自动调用。(同样,提交0f509703在两个回购中都不存在;同样,完全相同的回购,完全相同,这在macOS上不会发生——只在Travis的Linux机器上发生。)

我有同样的错误:

radato$ git submodule update 
fatal: git upload-pack: not our ref somehash0
fatal: remote error: upload-pack: not our ref somehash0
fatal: Fetched in submodule path 'dashboard', but it did not contain somehash0. Direct fetching of that commit failed.

所以我取消了子模块的初始化:

radato$ git submodule deinit -f dashboard
Cleared directory 'dashboard'
Submodule 'dashboard' (ssh://git@bitbucket.org/somedomain/dashboard.git) unregistered for path 'dashboard'

现在查看摘要我得到

radato@$ git submodule summary 
* somepath1 somehash1 (2):
< Merged in fixed_edge (pull request #2)
< fixed broken test
* somepath2 somehash2 (2):
< Merged in dsp_tx_freq (pull request #14)
< Merged in v0.2.0 (pull request #13)

最终我拉了:

radato@$ git pull --prune --recurse-submodules --force 
Fetching submodule dashboard
Fetching submodule somepath1
Fetching submodule somepath2
Already up to date.
Submodule path 'somesubmodulepath1': checked out 'somehash1'
Submodule path 'somesubmodulepath2': checked out 'somehash2'

现在它又起作用了。这是的状态

radato$ git status 
On branch develop
Your branch is up to date with 'origin/develop'.
nothing to commit, working tree clean

这尤其令人困惑,因为无论是主repo-bs-sedlex还是git子模块ppx-sedlex,都没有任何以0f5097…开头的提交。。。;

但他们可能有一个带有SHA1的标签(一旦取消引用,就会指向提交)

;致命:远程错误:上传包:不是我们的参考;误差表示;

参见";克隆具有嵌套子模块的repo不起作用";

Git提供了三个选项来控制是否可以获取任意对象ID:

  • 一个允许获取Git可以访问的任意对象的程序
  • 其允许从引用获取任何可到达的对象
  • 以及另外允许从隐藏引用获取可访问的对象的方法

;而不是我们的参考";消息意味着您正试图通过用于子模块的对象ID来获取对象,但服务器不允许这样做

在您的情况下,可能是:

  • 子模块中的标记从未被推送
  • 或者(因为它是从其他来源工作的)Travis CI不能访问子模块(私有依赖关系):参见";Travis CI中的Git-子模块">
    或者它有该子模块的某个缓存版本

老问题,但由于没有确切的答案:如果远程上没有引用,就会发生这种情况,这可能有几个原因:

  • 它属于一个已删除的标记
  • 它属于一个已被移除的分支
  • 存储库被强制推送,引用不属于新报告数据的一部分
  • 存在某种访问限制,使引用成为私有引用,您无法访问该引用
  • 当然还有几个原因

在任何情况下,您都应该能够摆脱这种混乱,方法是删除您自己的陈旧元数据,并从git中获取一个新的树,如其他答案中所述。

在我的案例中,我通过执行git reset --hard <for sure more than 100 commits before ref>解决了这个问题。

然后我简单地做了git pull,它成功了。由于它与程序一起工作,我没有尝试任何其他方法,所以我无法提供一种确定的方法来解决这个问题。

在Arch PKGBUILD上运行到该命令,搜索发现该命令git submodule sync用于kame工具git

我在PPSSP的PKGBUILD中发现了一个类似的问题,并添加了git submodule sync修复了它。但不知道为什么。

==> Starting prepare()...
fatal: git upload-pack: not our ref 4524b3a324ae8e9dcaf80c4fe3694bc63628de22
fatal: remote error: upload-pack: not our ref 4524b3a324ae8e9dcaf80c4fe3694bc63628de22
fatal: Fetched in submodule path 'buildtools', but it did not contain 
4524b3a324ae8e9dcaf80c4fe3694bc63628de22. Direct fetching of that commit failed.

pkg维护人员的修复程序如下diff:所示

diff --git a/PKGBUILD b/PKGBUILD
index 3d3ea9ed024..37d01b46467 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,7 +1,7 @@
# Maintainer: beelzy
pkgname=kame-tools-git
pkgver=5ae1ae1
-pkgrel=2
+pkgrel=3
pkgdesc="A tool for bundling 3DS theme files"
arch=('i686' 'x86_64' 'aarch64')
url="https://gitlab.com/beelzy/kame-tools"
@@ -12,8 +12,8 @@ depends=('gcc-libs')
_gitroot='https://gitlab.com/beelzy/kame-tools.git'
_gitname='kame-tools'

-source=("${_gitname}::git+${_gitroot}"
-        "buildtools::git+https://github.com/Steveice10/buildtools.git")
+source=("git+${_gitroot}"
+        "git+https://github.com/Steveice10/buildtools.git")
sha256sums=('SKIP' 'SKIP')

pkgver() {
@@ -24,7 +24,9 @@ pkgver() {
prepare() {
cd "$srcdir/$_gitname"
git submodule init
-    git submodule--helper update
+    git config submodule.buildtools.url $srcdir/buildtools
+    git submodule sync
+    git -c protocol.file.allow=always submodule update
cd buildtools
git apply ../aarch64.patch
}

可能的诊断:错误的上游远程url

我在尝试更新子模块时遇到了这个错误,问题是子模块远程不正确。

看看这是否是你的问题:

  1. 请检查.gitmodules文件中的远程url,查找出现问题的子模块
  2. 现在cd进入子模块并运行git remote get-url origin

这些URL应该匹配。如果它们不匹配,那么您/您的组织可能从其他地方派生了一个子模块并对其进行了更新,并且您需要在本地手动更新上游远程url。

解决方案

.gitmodules文件可能是正确的,因为派生子模块的人应该已经更新了.gitmodules文件以指向正确的子模块。

因此:

  1. .gitmodules复制远程URL
  2. cd返回子模块目录
  3. 运行git remote set-url origin PASTE_URL_HERE
  4. 检查git remote get-url origin并确认它现在与.gitmodules文件匹配
  5. 在项目根目录下重新运行git submodule update --init --recursive

希望它能帮助到别人!

https://developer.matomo.org/guides/git"修复参考错误当您忘记推送子模块时假设您在子模块中进行了一些更改。然后你提交了这些更改,但你忘记了推动如下更改:

cd plugins/SecurityInfo.
git checkout -b $MY_FEATURE_BRANCH $MAIN_BRANCH.
git add Controller.php && git commit -m "Update".
Here usually a push should happen, but you forgot it.
cd ../..
git add plugins/SecurityInfo this stages the submodule reference change
git commit -m 'Update submodule'
git push
When you push now, then the updating of the submodule won't work because the commit only exists on your local computer but was never pushed. "

要解决此问题,请执行以下操作:您可以提取一个确实存在的提交,并使用旧的提交更新主分支。https://unfuddle.com/stack/tips-tricks/git-pull-specific-commit/

我在github操作中也遇到了这个问题。事实证明,操作/签出只获取特定的提交,而不是整个分支历史,所以当提取子模块时,它会中断。

确保您使用fetch-depth: 0:签出整个回购

- uses: actions/checkout@v4
with:
fetch-depth: 0

相关内容

最新更新