Git子模块获取错误的提交哈希



我正在运行以下命令

export GIT_TRACE=1
$ git clone git@github.org.com:org/project.git
$ cd project
$ git fetch --force --no-tags --no-recurse-submodules origin refs/heads/project-3.4
$ git checkout -B project-3.4 origin/project-3.4
$ git -C . submodule update --init --remote project-buildscripts
$ cd project-buildscripts
$ git checkout 4i790d3
$ cd ..

直到现在一切似乎都很好。。。然后我运行

$ git fetch origin
18:10:08.504581 git.c:444               trace: built-in: git fetch origin
18:10:08.510629 run-command.c:663       trace: run_command: unset GIT_PREFIX; ssh git@github.org.com 'git-upload-pack '''pie/project.git''''
remote: Enumerating objects: 3160, done.
remote: Counting objects: 100% (3160/3160), done.
remote: Compressing objects: 100% (27/27), done.
18:10:09.373335 run-command.c:663       trace: run_command: git index-pack --stdin -v --fix-thin '--keep=fetch-pack 85369 on Machine.local' --pack_header=2,8661
18:10:09.380636 git.c:444               trace: built-in: git index-pack --stdin -v --fix-thin '--keep=fetch-pack 85369 on Machine.local' --pack_header=2,8661
remote: Total 8661 (delta 3136), reused 3143 (delta 3133), pack-reused 5501
Receiving objects: 100% (8661/8661), 4.72 MiB | 3.25 MiB/s, done.
Resolving deltas: 100% (5230/5230), completed with 598 local objects.
18:10:11.429321 run-command.c:663       trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs
18:10:11.435057 git.c:444               trace: built-in: git rev-list --objects --stdin --not --all --quiet --alternate-refs
From github.org.com:pie/project
+ 09aa5f74...4fe45193 project-3.4                       -> origin/project-3.4  (forced update)
* [new branch]        app-logging                       -> origin/app-logging
... [bunch of other branches]
18:10:11.618055 run-command.c:1617      run_processes_parallel: preparing to run up to 1 tasks
18:10:11.618710 run-command.c:663       trace: run_command: cd /Users/local/junkyard/submod/project/.git/modules/project-buildscripts; unset GIT_PREFIX; GIT_DIR=. git fetch --no-prune --no-prune-tags --recurse-submodules-default on-demand --submodule-prefix project-buildscripts/
Fetching submodule project-buildscripts
18:10:11.625640 git.c:444               trace: built-in: git fetch --no-prune --no-prune-tags --recurse-submodules-default on-demand --submodule-prefix project-buildscripts/
18:10:11.627202 run-command.c:663       trace: run_command: unset GIT_DIR GIT_PREFIX; ssh git@github.org.com 'git-upload-pack '''pie/project-buildscripts.git''''
18:10:12.085406 run-command.c:663       trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs
18:10:12.094694 run-command.c:663       trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs
18:10:12.100317 git.c:444               trace: built-in: git rev-list --objects --stdin --not --all --quiet --alternate-refs
18:10:12.126601 run-command.c:1617      run_processes_parallel: preparing to run up to 1 tasks
18:10:12.126624 run-command.c:1649      run_processes_parallel: done
18:10:12.126647 run-command.c:663       trace: run_command: git gc --auto
18:10:12.133044 git.c:444               trace: built-in: git gc --auto
18:10:12.135664 run-command.c:663       trace: run_command: cd /Users/local/junkyard/submod/project/.git/modules/project-buildscripts; unset GIT_PREFIX; GIT_DIR=. git fetch --no-prune --no-prune-tags --recurse-submodules-default on-demand --submodule-prefix project-buildscripts/ origin 54eb8df72c5bd87a93407354ca1e16394c58e15f
18:10:12.142435 git.c:444               trace: built-in: git fetch --no-prune --no-prune-tags --recurse-submodules-default on-demand --submodule-prefix project-buildscripts/ origin 58ff9df72c5bd87a93407354ca1e16394c58e15f
18:10:12.144087 run-command.c:663       trace: run_command: unset GIT_DIR GIT_PREFIX; ssh git@github.org.com 'git-upload-pack '''pie/project-buildscripts.git''''
error: Server does not allow request for unadvertised object 58ff9df72c5bd87a93407354ca1e16394c58e15f
18:10:12.783758 run-command.c:663       trace: run_command: git gc --auto
18:10:12.791054 git.c:444               trace: built-in: git gc --auto
18:10:12.792972 run-command.c:1649      run_processes_parallel: done
Errors during submodule fetch:
project-buildscripts
18:10:12.793291 run-command.c:663       trace: run_command: git gc --auto
18:10:12.799263 git.c:444               trace: built-in: git gc --auto

我已经确保我将submodulecheckout作为最新的提交,但不知何故,它仍然引用了一个现在不存在的提交(在子模块目录中强制推送(。

4i790d3-新提交

58ff9df72c5bd87a93407354ca1e16394c58e15f-由于过去中的强制推送而丢失的旧提交

我如何绕过这个问题并实际解决这个问题?非常感谢。

GitHub Enterprise Server 2.19.17

Github Client - 2.28.0

此消息意味着服务器不允许您获取不是引用头的对象。这是Git的默认行为,所以这并不奇怪。

您可以尝试打开v2协议,因为Git核心服务器端实现不使用v2协议执行此限制。您可以通过运行git config --global protocol.version 2来做到这一点。然而,您运行的GitHub Enterprise Server版本可能太旧,无法支持它,在这种情况下,没有一个简单的解决方案。

如果提交可以从任何现有的ref访问,那么你可能只需要手动克隆子模块,Git就会更新它,但如果对象真的没有被引用,那么如果以上不起作用,你就倒霉了。

请注意,较新版本的GitHub Enterprise Server在这里也可能有所帮助,因为对于部分克隆,必须禁用服务器端选项。因此,如果你的GHES版本支持部分克隆,那么无论你是否使用v2协议,这都应该有效。

最新更新