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

发布于 2025-01-11 03:38:37 字数 10279 浏览 0 评论 0原文

我们只在 CI 上看到一个奇怪的错误。我们有一个 git 存储库(我们称之为“OUTER”),其中包含一个子模块(“INNER”)。如果我们在开发机器上正常克隆“OUTER”并更新子模块,我们不会发现任何问题。在 CI 上,Bitrise 以奇怪的方式“克隆”存储库后,在尝试获取子模块时调用 git fetch 会引发错误。

这是一个示例输出。请注意,前几行模拟 Bitrise 如何“克隆”存储库。

➜ test git "init"
git "remote" "add" "origin" "[email protected]:COMPANY/OUTER.git"
git "fetch" "--jobs=10" "--no-tags" "origin" "refs/heads/master"
git "checkout" "master"
git "merge" "origin/master"
git "submodule" "update" "--init" "--recursive" "--jobs=10"

hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint:   git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint:   git branch -m <name>
Initialized empty Git repository in /Users/lnatan/Desktop/test/.git/
remote: Enumerating objects: 48542, done.
remote: Counting objects: 100% (4094/4094), done.
remote: Compressing objects: 100% (989/989), done.
remote: Total 48542 (delta 3383), reused 3623 (delta 3082), pack-reused 44448
Receiving objects: 100% (48542/48542), 178.80 MiB | 5.71 MiB/s, done.
Resolving deltas: 100% (35468/35468), done.
From github.com:COMPANY/OUTER
 * branch              master     -> FETCH_HEAD
 * [new branch]        master     -> origin/master
Branch 'master' set up to track remote branch 'master' from 'origin'.
Already on 'master'
Already up to date.
Submodule 'Submodules/INNER' ([email protected]:COMPANY/INNER.git) registered for path 'Submodules/INNER'
Cloning into '/Users/lnatan/Desktop/test/Submodules/INNER'...
Submodule path 'Submodules/INNER': checked out '174a9f60014e3cead89242178c534aeaff769dc7'
➜  test git:(master) 
➜  test git:(master)                                                                                                                                                                                             
➜  test git:(master) 
➜  test git:(master) git fetch
remote: Enumerating objects: 9001, done.
remote: Counting objects: 100% (4953/4953), done.
remote: Compressing objects: 100% (2833/2833), done.
remote: Total 4461 (delta 3443), reused 2361 (delta 1527), pack-reused 0
Receiving objects: 100% (4461/4461), 6.16 MiB | 3.41 MiB/s, done.
Resolving deltas: 100% (3443/3443), completed with 399 local objects.
From github.com:COMPANY/OUTER
 = [up to date]        master                                              -> origin/master
 * [new branch]        ...
 * [new tag]           ...
Fetching submodule Submodules/INNER
fatal: remote error: upload-pack: not our ref 57df880c914a482c26a1db9b388a34ee55e22730
Errors during submodule fetch:
    Submodules/INNER

使用 GIT_TRACE=2--verbose 会产生以下输出:

➜  test git:(master) GIT_TRACE=2 git fetch --tags --verbose
02:04:41.644506 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/bin/git
02:04:41.644795 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/bin
02:04:41.645153 git.c:455               trace: built-in: git fetch --tags --verbose
02:04:41.645516 run-command.c:667       trace: run_command: unset GIT_PREFIX; GIT_PROTOCOL=version=2 ssh -o SendEnv=GIT_PROTOCOL [email protected] 'git-upload-pack '\''COMPANY/OUTER.git'\'''
remote: Enumerating objects: 9300, done.
remote: Counting objects: 100% (5243/5243), done.
remote: Compressing objects: 100% (3091/3091), done.
02:04:48.411851 run-command.c:667       trace: run_command: git index-pack --stdin -v --fix-thin '--keep=fetch-pack 30246 on Leo-Natans-Inv-MBP.local' --pack_header=2,4750
02:04:48.417901 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
02:04:48.418587 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
02:04:48.419008 git.c:455               trace: built-in: git index-pack --stdin -v --fix-thin '--keep=fetch-pack 30246 on Leo-Natans-Inv-MBP.local' --pack_header=2,4750
remote: Total 4750 (delta 3673), reused 2442 (delta 1552), pack-reused 0
Receiving objects: 100% (4750/4750), 6.22 MiB | 3.51 MiB/s, done.
Resolving deltas: 100% (3673/3673), completed with 400 local objects.
02:04:50.742376 run-command.c:667       trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs
02:04:50.747795 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
02:04:50.748441 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
02:04:50.748944 git.c:455               trace: built-in: git rev-list --objects --stdin --not --all --quiet --alternate-refs
From github.com:COMPANY/OUTER
 = [up to date]        master                                              -> origin/master
 * [new branch]        ...
 * [new tag]           ...
02:04:51.133204 run-command.c:1628      run_processes_parallel: preparing to run up to 1 tasks
02:04:51.133359 run-command.c:667       trace: run_command: cd /Users/lnatan/Desktop/test/.git/modules/Submodules/INNER; unset GIT_PREFIX; GIT_DIR=. git fetch --no-prune --no-prune-tags --tags -v --recurse-submodules-default on-demand --submodule-prefix Submodules/INNER/
Fetching submodule Submodules/INNER
02:04:51.135930 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
02:04:51.136231 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
02:04:51.136416 git.c:455               trace: built-in: git fetch --no-prune --no-prune-tags --tags -v --recurse-submodules-default on-demand --submodule-prefix Submodules/INNER/
02:04:51.136872 run-command.c:667       trace: run_command: unset GIT_DIR GIT_PREFIX; GIT_PROTOCOL=version=2 ssh -o SendEnv=GIT_PROTOCOL [email protected] 'git-upload-pack '\''COMPANY/INNER.git'\'''
02:04:55.589678 run-command.c:667       trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs
02:04:55.600024 run-command.c:667       trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs
02:04:55.603178 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
02:04:55.603586 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
02:04:55.603916 git.c:455               trace: built-in: git rev-list --objects --stdin --not --all --quiet --alternate-refs
From github.com:COMPANY/INNER
 = [up to date]      ...
02:04:55.938232 run-command.c:1628      run_processes_parallel: preparing to run up to 1 tasks
02:04:55.938375 run-command.c:1660      run_processes_parallel: done
02:04:55.938496 run-command.c:667       trace: run_command: git maintenance run --auto --no-quiet
02:04:55.946682 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
02:04:55.947423 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
02:04:55.948094 git.c:455               trace: built-in: git maintenance run --auto --no-quiet
02:04:55.951412 run-command.c:667       trace: run_command: cd /Users/lnatan/Desktop/test/.git/modules/Submodules/INNER; unset GIT_PREFIX; GIT_DIR=. git fetch --no-prune --no-prune-tags --tags -v --recurse-submodules-default on-demand --submodule-prefix Submodules/INNER/ origin 57df880c914a482c26a1db9b388a34ee55e22730
02:04:55.956634 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
02:04:55.957121 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
02:04:55.957479 git.c:455               trace: built-in: git fetch --no-prune --no-prune-tags --tags -v --recurse-submodules-default on-demand --submodule-prefix Submodules/INNER/ origin 57df880c914a482c26a1db9b388a34ee55e22730
02:04:55.958394 run-command.c:667       trace: run_command: unset GIT_DIR GIT_PREFIX; GIT_PROTOCOL=version=2 ssh -o SendEnv=GIT_PROTOCOL [email protected] 'git-upload-pack '\''COMPANY/INNER.git'\'''
fatal: remote error: upload-pack: not our ref 57df880c914a482c26a1db9b388a34ee55e22730
02:05:00.643367 run-command.c:1660      run_processes_parallel: done
Errors during submodule fetch:
    Submodules/INNER
02:05:00.644990 run-command.c:667       trace: run_command: git maintenance run --auto --no-quiet
02:05:00.652674 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
02:05:00.653655 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
02:05:00.654379 git.c:455               trace: built-in: git maintenance run --auto --no-quiet

我无法弄清楚 57df880c914a482c26a1db9b388a34ee55e22730 来自哪里。我在任何地方都找不到任何关于它的参考,但我可能不知道去哪里寻找。有什么帮助吗?

谢谢

We are seeing an odd error only on our CI. We have a git repository (let's call it "OUTER") which contains one submodule ("INNER"). If we clone "OUTER" normally on our development machines and update submodules, we see no issues. On CI, after the odd way Bitrise "clones" the repo, calling git fetch throws an error when attempting to fetch the submodule.

Here is an example output. Notice the first few lines simulate how Bitrise "clones" the repo.

➜ test git "init"
git "remote" "add" "origin" "[email protected]:COMPANY/OUTER.git"
git "fetch" "--jobs=10" "--no-tags" "origin" "refs/heads/master"
git "checkout" "master"
git "merge" "origin/master"
git "submodule" "update" "--init" "--recursive" "--jobs=10"

hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint:   git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint:   git branch -m <name>
Initialized empty Git repository in /Users/lnatan/Desktop/test/.git/
remote: Enumerating objects: 48542, done.
remote: Counting objects: 100% (4094/4094), done.
remote: Compressing objects: 100% (989/989), done.
remote: Total 48542 (delta 3383), reused 3623 (delta 3082), pack-reused 44448
Receiving objects: 100% (48542/48542), 178.80 MiB | 5.71 MiB/s, done.
Resolving deltas: 100% (35468/35468), done.
From github.com:COMPANY/OUTER
 * branch              master     -> FETCH_HEAD
 * [new branch]        master     -> origin/master
Branch 'master' set up to track remote branch 'master' from 'origin'.
Already on 'master'
Already up to date.
Submodule 'Submodules/INNER' ([email protected]:COMPANY/INNER.git) registered for path 'Submodules/INNER'
Cloning into '/Users/lnatan/Desktop/test/Submodules/INNER'...
Submodule path 'Submodules/INNER': checked out '174a9f60014e3cead89242178c534aeaff769dc7'
➜  test git:(master) 
➜  test git:(master)                                                                                                                                                                                             
➜  test git:(master) 
➜  test git:(master) git fetch
remote: Enumerating objects: 9001, done.
remote: Counting objects: 100% (4953/4953), done.
remote: Compressing objects: 100% (2833/2833), done.
remote: Total 4461 (delta 3443), reused 2361 (delta 1527), pack-reused 0
Receiving objects: 100% (4461/4461), 6.16 MiB | 3.41 MiB/s, done.
Resolving deltas: 100% (3443/3443), completed with 399 local objects.
From github.com:COMPANY/OUTER
 = [up to date]        master                                              -> origin/master
 * [new branch]        ...
 * [new tag]           ...
Fetching submodule Submodules/INNER
fatal: remote error: upload-pack: not our ref 57df880c914a482c26a1db9b388a34ee55e22730
Errors during submodule fetch:
    Submodules/INNER

Using GIT_TRACE=2 and --verbose produces the following output:

➜  test git:(master) GIT_TRACE=2 git fetch --tags --verbose
02:04:41.644506 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/bin/git
02:04:41.644795 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/bin
02:04:41.645153 git.c:455               trace: built-in: git fetch --tags --verbose
02:04:41.645516 run-command.c:667       trace: run_command: unset GIT_PREFIX; GIT_PROTOCOL=version=2 ssh -o SendEnv=GIT_PROTOCOL [email protected] 'git-upload-pack '\''COMPANY/OUTER.git'\'''
remote: Enumerating objects: 9300, done.
remote: Counting objects: 100% (5243/5243), done.
remote: Compressing objects: 100% (3091/3091), done.
02:04:48.411851 run-command.c:667       trace: run_command: git index-pack --stdin -v --fix-thin '--keep=fetch-pack 30246 on Leo-Natans-Inv-MBP.local' --pack_header=2,4750
02:04:48.417901 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
02:04:48.418587 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
02:04:48.419008 git.c:455               trace: built-in: git index-pack --stdin -v --fix-thin '--keep=fetch-pack 30246 on Leo-Natans-Inv-MBP.local' --pack_header=2,4750
remote: Total 4750 (delta 3673), reused 2442 (delta 1552), pack-reused 0
Receiving objects: 100% (4750/4750), 6.22 MiB | 3.51 MiB/s, done.
Resolving deltas: 100% (3673/3673), completed with 400 local objects.
02:04:50.742376 run-command.c:667       trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs
02:04:50.747795 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
02:04:50.748441 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
02:04:50.748944 git.c:455               trace: built-in: git rev-list --objects --stdin --not --all --quiet --alternate-refs
From github.com:COMPANY/OUTER
 = [up to date]        master                                              -> origin/master
 * [new branch]        ...
 * [new tag]           ...
02:04:51.133204 run-command.c:1628      run_processes_parallel: preparing to run up to 1 tasks
02:04:51.133359 run-command.c:667       trace: run_command: cd /Users/lnatan/Desktop/test/.git/modules/Submodules/INNER; unset GIT_PREFIX; GIT_DIR=. git fetch --no-prune --no-prune-tags --tags -v --recurse-submodules-default on-demand --submodule-prefix Submodules/INNER/
Fetching submodule Submodules/INNER
02:04:51.135930 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
02:04:51.136231 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
02:04:51.136416 git.c:455               trace: built-in: git fetch --no-prune --no-prune-tags --tags -v --recurse-submodules-default on-demand --submodule-prefix Submodules/INNER/
02:04:51.136872 run-command.c:667       trace: run_command: unset GIT_DIR GIT_PREFIX; GIT_PROTOCOL=version=2 ssh -o SendEnv=GIT_PROTOCOL [email protected] 'git-upload-pack '\''COMPANY/INNER.git'\'''
02:04:55.589678 run-command.c:667       trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs
02:04:55.600024 run-command.c:667       trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs
02:04:55.603178 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
02:04:55.603586 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
02:04:55.603916 git.c:455               trace: built-in: git rev-list --objects --stdin --not --all --quiet --alternate-refs
From github.com:COMPANY/INNER
 = [up to date]      ...
02:04:55.938232 run-command.c:1628      run_processes_parallel: preparing to run up to 1 tasks
02:04:55.938375 run-command.c:1660      run_processes_parallel: done
02:04:55.938496 run-command.c:667       trace: run_command: git maintenance run --auto --no-quiet
02:04:55.946682 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
02:04:55.947423 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
02:04:55.948094 git.c:455               trace: built-in: git maintenance run --auto --no-quiet
02:04:55.951412 run-command.c:667       trace: run_command: cd /Users/lnatan/Desktop/test/.git/modules/Submodules/INNER; unset GIT_PREFIX; GIT_DIR=. git fetch --no-prune --no-prune-tags --tags -v --recurse-submodules-default on-demand --submodule-prefix Submodules/INNER/ origin 57df880c914a482c26a1db9b388a34ee55e22730
02:04:55.956634 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
02:04:55.957121 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
02:04:55.957479 git.c:455               trace: built-in: git fetch --no-prune --no-prune-tags --tags -v --recurse-submodules-default on-demand --submodule-prefix Submodules/INNER/ origin 57df880c914a482c26a1db9b388a34ee55e22730
02:04:55.958394 run-command.c:667       trace: run_command: unset GIT_DIR GIT_PREFIX; GIT_PROTOCOL=version=2 ssh -o SendEnv=GIT_PROTOCOL [email protected] 'git-upload-pack '\''COMPANY/INNER.git'\'''
fatal: remote error: upload-pack: not our ref 57df880c914a482c26a1db9b388a34ee55e22730
02:05:00.643367 run-command.c:1660      run_processes_parallel: done
Errors during submodule fetch:
    Submodules/INNER
02:05:00.644990 run-command.c:667       trace: run_command: git maintenance run --auto --no-quiet
02:05:00.652674 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
02:05:00.653655 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
02:05:00.654379 git.c:455               trace: built-in: git maintenance run --auto --no-quiet

I can't figure out where 57df880c914a482c26a1db9b388a34ee55e22730 comes from. I cannot find any reference to it anywhere, but I might not know where to look. Any assistance?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尛丟丟 2025-01-18 03:38:37

57df880c914a482c26a1db9b388a34ee55e22730 来自超级项目(引用子模块的存储库)中的提交。您的 git fetch 操作正在“递归”模式下运行,它尝试使用超级项目中的指令在每个子模块中运行 git fetch 。不幸的是,超级项目中的指令要么完全错误,要么对于远程(子模块最初克隆的位置)上的 Git 软件来说无法理解。

正如您在您自己的评论中指出的,git fetch --no-recurse-submodules 避免尝试运行该特定提交的递归获取。您还可以使用 git config fetch.recurseSubmodules false 默认关闭递归。将其设置为按需在这里可能有效,也可能无效。

57df880c914a482c26a1db9b388a34ee55e22730 comes from a commit in the superproject (the repository that refers to the submodule). Your git fetch operation is running in "recursive" mode, where it is trying to use the instructions in the superproject to run git fetch in each submodule. Unfortunately the instructions in the superproject are either completely wrong, or unintelligible to the Git software on the remote (the place from which the submodule was initially cloned).

As you noted in your own comment, git fetch --no-recurse-submodules avoids trying to run a recursive fetch of that one specific commit. You could also configure recursion off by default, with git config fetch.recurseSubmodules false. Setting it to on-demand may or may not work here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文