Windows 10上的Git子模块命令非常慢

问题描述

Git submodule命令在当前Windows 10上非常慢(至少在使用BitBucket时,没有尝试任何其他服务器)。

我有一个带有单个子模块的简单存储库,其中包含2个小文本文件(整个子模块存储库为20kb)。如果我分别clone两个仓库,我将在1-5秒内得到它们。

git submodule init大约需要5-10秒。
git submodule update花费〜 2分钟
git submodule update --initgit submodule add https://bitbucket.org/...显示相同的结果。
--progress标志什么都不显示。

我尝试在pwsh(Windows终端)和普通的cmd中运行它们,结果相同。
我尝试了SSH和HTTPS。

我已经读过此git submodule update is slow. How can I debug why it's slow?
我从这里Git submodule update slow on Windows

尝试了命令
cmd /V /C "set GIT_TRACE2_PERF=C:/Users/me/log.perf&& git submodule update"

并得到以下结果(删除了2列:1列刚刚说main,另一列有重复时间):

21:16:29.755412 common-main.c:48             | d0 | version      |     |           |              | 2.28.0.windows.1
21:16:29.756420 common-main.c:49             | d0 | start        |     |  0.035490 |              | git.exe submodule update
21:16:29.770717 ..._win32_process_info.c:118 | d0 | data_json    | r0  |  0.049596 | process      | windows/ancestry:["git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","explorer.exe"]
21:16:29.771683 git.c:698                    | d0 | cmd_name     |     |           |              | _run_dashed_ (_run_dashed_)
21:16:29.772683 run-command.c:735            | d0 | child_start  |     |  0.051473 |              | [ch0] class:dashed argv:[git-submodule update]
21:16:44.141790 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:16:44.142817 common-main.c:49             | d1 | start        |     |  0.036516 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' --exec-path
21:16:44.163835 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.057664 | process      | windows/ancestry:["sh.exe","sh.exe","git.exe","explorer.exe"]
21:16:44.163835 git.c:159                    | d1 | cmd_name     |     |           |              | _query_ (_run_dashed_/_query_)
21:16:44.163835 ..._win32_process_info.c:166 | d1 | data_json    | r0  |  0.058116 | process      | windows/memory:{"PageFaultCount":9464,"PeakWorkingSetSize":7643136,"PeakPagefileUsage":3694592}
21:16:44.163835 git.c:160                    | d1 | exit         |     |  0.058139 |              | code:0
21:16:44.163835 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.058152 |              | code:0
21:17:02.539359 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:02.540357 common-main.c:49             | d1 | start        |     |  0.049746 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
21:17:02.568368 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.077844 | process      | windows/ancestry:["sh.exe","(truncated)"]
21:17:02.570378 git.c:698                    | d1 | cmd_name     |     |           |              | _run_dashed_ (_run_dashed_/_run_dashed_)
21:17:02.570378 run-command.c:735            | d1 | child_start  |     |  0.080189 |              | [ch0] class:dashed argv:[git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE']
21:17:02.649337 common-main.c:48             | d2 | version      |     |           |              | 2.28.0.windows.1
21:17:02.651034 common-main.c:49             | d2 | start        |     |  0.046435 |              | git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
21:17:02.676042 ..._win32_process_info.c:118 | d2 | data_json    | r0  |  0.072334 | process      | windows/ancestry:["git.exe","(truncated)"]
21:17:02.677049 sh-i18n--envsubst.c:71       | d2 | cmd_name     |     |           |              | sh-i18n--envsubst (_run_dashed_/_run_dashed_/sh-i18n--envsubst)
21:17:02.677049 ..._win32_process_info.c:166 | d2 | data_json    | r0  |  0.072955 | process      | windows/memory:{"PageFaultCount":9935,"PeakWorkingSetSize":7585792,"PeakPagefileUsage":3579904}
21:17:02.677049 sh-i18n--envsubst.c:112      | d2 | exit         |     |  0.072989 |              | code:0
21:17:02.677049 trace2/tr2_tgt_perf.c:213    | d2 | atexit       |     |  0.073002 |              | code:0
21:17:02.681054 run-command.c:990            | d1 | child_exit   |     |  0.191162 |              | [ch0] pid:25708 code:0
21:17:02.682046 ..._win32_process_info.c:166 | d1 | data_json    | r0  |  0.191827 | process      | windows/memory:{"PageFaultCount":9888,"PeakWorkingSetSize":7647232,"PeakPagefileUsage":3702784}
21:17:02.682046 git.c:720                    | d1 | exit         |     |  0.191901 |              | code:0
21:17:02.682046 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.191942 |              | code:0
21:17:04.796883 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:04.797907 common-main.c:49             | d1 | start        |     |  0.039257 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' sh-i18n--envsubst 'usage: $dashless $USAGE'
21:17:04.819927 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.061218 | process      | windows/ancestry:["sh.exe","explorer.exe","(truncated)"]
21:17:04.821156 git.c:698                    | d1 | cmd_name     |     |           |              | _run_dashed_ (_run_dashed_/_run_dashed_)
21:17:04.821156 run-command.c:735            | d1 | child_start  |     |  0.062881 |              | [ch0] class:dashed argv:[git-sh-i18n--envsubst 'usage: $dashless $USAGE']
21:17:04.884374 common-main.c:48             | d2 | version      |     |           |              | 2.28.0.windows.1
21:17:04.884374 common-main.c:49             | d2 | start        |     |  0.037532 |              | git-sh-i18n--envsubst 'usage: $dashless $USAGE'
21:17:04.906374 ..._win32_process_info.c:118 | d2 | data_json    | r0  |  0.059654 | process      | windows/ancestry:["git.exe","(truncated)"]
21:17:04.907374 sh-i18n--envsubst.c:71       | d2 | cmd_name     |     |           |              | sh-i18n--envsubst (_run_dashed_/_run_dashed_/sh-i18n--envsubst)
21:17:04.907374 ..._win32_process_info.c:166 | d2 | data_json    | r0  |  0.060129 | process      | windows/memory:{"PageFaultCount":9842,"PeakWorkingSetSize":7614464,"PeakPagefileUsage":3596288}
21:17:04.907374 sh-i18n--envsubst.c:112      | d2 | exit         |     |  0.060156 |              | code:0
21:17:04.907374 trace2/tr2_tgt_perf.c:213    | d2 | atexit       |     |  0.060171 |              | code:0
21:17:04.909410 run-command.c:990            | d1 | child_exit   |     |  0.151444 |              | [ch0] pid:19968 code:0
21:17:04.910465 ..._win32_process_info.c:166 | d1 | data_json    | r0  |  0.151876 | process      | windows/memory:{"PageFaultCount":9505,"PeakWorkingSetSize":7655424,"PeakPagefileUsage":3694592}
21:17:04.910465 git.c:720                    | d1 | exit         |     |  0.151945 |              | code:0
21:17:04.910465 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.151989 |              | code:0
21:17:15.186324 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:15.187272 common-main.c:49             | d1 | start        |     |  0.034928 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' rev-parse --git-dir
21:17:15.208271 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.055569 | process      | windows/ancestry:["sh.exe","explorer.exe"]
21:17:15.208271 git.c:445                    | d1 | cmd_name     |     |           |              | rev-parse (_run_dashed_/rev-parse)
21:17:15.209664 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:15.210099 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.057842 | process      | windows/memory:{"PageFaultCount":9505,"PeakWorkingSetSize":7639040,"PeakPagefileUsage":3690496}
21:17:15.210099 git.c:675                    | d1 | exit         |     |  0.057867 |              | code:0
21:17:15.211106 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.057883 |              | code:0
21:17:21.377950 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:21.378952 common-main.c:49             | d1 | start        |     |  0.035100 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' rev-parse --git-path objects
21:17:21.401951 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.058018 | process      | windows/ancestry:["sh.exe","explorer.exe"]
21:17:21.401951 git.c:445                    | d1 | cmd_name     |     |           |              | rev-parse (_run_dashed_/rev-parse)
21:17:21.402950 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:21.403950 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.060304 | process      | windows/memory:{"PageFaultCount":9505,"PeakPagefileUsage":3694592}
21:17:21.403950 git.c:675                    | d1 | exit         |     |  0.060327 |              | code:0
21:17:21.403950 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.060339 |              | code:0
21:17:25.560719 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:25.560719 common-main.c:49             | d1 | start        |     |  0.036064 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' rev-parse -q --git-dir
21:17:25.581725 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.056848 | process      | windows/ancestry:["sh.exe","explorer.exe"]
21:17:25.581725 git.c:445                    | d1 | cmd_name     |     |           |              | rev-parse (_run_dashed_/rev-parse)
21:17:25.582726 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:25.583726 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.059098 | process      | windows/memory:{"PageFaultCount":9507,"PeakPagefileUsage":3694592}
21:17:25.583726 git.c:675                    | d1 | exit         |     |  0.059122 |              | code:0
21:17:25.583726 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.059133 |              | code:0
21:17:29.712244 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:29.712244 common-main.c:49             | d1 | start        |     |  0.033477 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' rev-parse --is-inside-work-tree
21:17:29.733278 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.054172 | process      | windows/ancestry:["sh.exe","explorer.exe"]
21:17:29.733278 git.c:445                    | d1 | cmd_name     |     |           |              | rev-parse (_run_dashed_/rev-parse)
21:17:29.734278 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:29.735842 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.056295 | process      | windows/memory:{"PageFaultCount":9488,"PeakWorkingSetSize":7573504,"PeakPagefileUsage":3657728}
21:17:29.735842 git.c:675                    | d1 | exit         |     |  0.056318 |              | code:0
21:17:29.735842 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.056330 |              | code:0
21:17:31.830544 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:31.831594 common-main.c:49             | d1 | start        |     |  0.036763 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' rev-parse --show-prefix
21:17:31.849588 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.055489 | process      | windows/ancestry:["sh.exe","explorer.exe"]
21:17:31.850579 git.c:445                    | d1 | cmd_name     |     |           |              | rev-parse (_run_dashed_/rev-parse)
21:17:31.851475 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:31.852166 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.057811 | process      | windows/memory:{"PageFaultCount":8766,"PeakWorkingSetSize":7634944,"PeakPagefileUsage":3690496}
21:17:31.852166 git.c:675                    | d1 | exit         |     |  0.057834 |              | code:0
21:17:31.852166 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.057846 |              | code:0
21:17:33.965947 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:33.965947 common-main.c:49             | d1 | start        |     |  0.037985 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' rev-parse --show-toplevel
21:17:33.984986 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.056903 | process      | windows/ancestry:["sh.exe","explorer.exe"]
21:17:33.984986 git.c:445                    | d1 | cmd_name     |     |           |              | rev-parse (_run_dashed_/rev-parse)
21:17:33.986529 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:33.986904 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.059073 | process      | windows/memory:{"PageFaultCount":8761,"PeakPagefileUsage":3694592}
21:17:33.986904 git.c:675                    | d1 | exit         |     |  0.059096 |              | code:0
21:17:33.987913 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.059111 |              | code:0
21:17:46.255798 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:46.255798 common-main.c:49             | d1 | start        |     |  0.036220 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' submodule--helper update-clone --
21:17:46.275839 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.056313 | process      | windows/ancestry:["sh.exe","explorer.exe"]
21:17:46.277436 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:46.277436 git.c:445                    | d1 | cmd_name     |     |           |              | submodule--helper (_run_dashed_/submodule--helper)
21:17:46.279459 read-cache.c:2315            | d1 | region_enter | r1  |  0.059520 | index        | label:do_read_index .git/index
21:17:46.279459 read-cache.c:2275            | d1 | data         | r1  |  0.059771 | index        | ..read/version:2
21:17:46.279459 read-cache.c:2277            | d1 | data         | r1  |  0.059807 | index        | ..read/cache_nr:89
21:17:46.279459 read-cache.c:2320            | d1 | region_leave | r1  |  0.059821 | index        | label:do_read_index .git/index
21:17:46.279459 run-command.c:1858           | d1 | region_enter |     |  0.059842 | submodule    | label:parallel/update max:1
21:17:46.280443 run-command.c:1864           | d1 | region_leave |     |  0.060144 | submodule    | label:parallel/update
21:17:46.280443 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.060496 | process      | windows/memory:{"PageFaultCount":9550,"PeakPagefileUsage":3706880}
21:17:46.280443 git.c:675                    | d1 | exit         |     |  0.060519 |              | code:0
21:17:46.280443 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.060531 |              | code:0
21:17:48.385295 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:48.386329 common-main.c:49             | d1 | start        |     |  0.034577 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' submodule--helper ensure-core-worktree api-configs
21:17:48.408296 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.057052 | process      | windows/ancestry:["sh.exe","explorer.exe"]
21:17:48.410313 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:48.411294 git.c:445                    | d1 | cmd_name     |     |           |              | submodule--helper (_run_dashed_/submodule--helper)
21:17:48.412306 read-cache.c:2315            | d1 | region_enter | r1  |  0.060851 | index        | label:do_read_index .git/index
21:17:48.412306 read-cache.c:2275            | d1 | data         | r1  |  0.061108 | index        | ..read/version:2
21:17:48.412306 read-cache.c:2277            | d1 | data         | r1  |  0.061128 | index        | ..read/cache_nr:89
21:17:48.412306 read-cache.c:2320            | d1 | region_leave | r1  |  0.061143 | index        | label:do_read_index .git/index
21:17:48.414294 repository.c:134             | d1 | def_repo     | r2  |           |              | worktree:C:/work/repos/test/api-template/api-configs
21:17:48.415807 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.064903 | process      | windows/memory:{"PageFaultCount":9546,"PeakPagefileUsage":3694592}
21:17:48.415807 git.c:675                    | d1 | exit         |     |  0.064926 |              | code:0
21:17:48.416807 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.064941 |              | code:0
21:17:50.520402 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:50.520402 common-main.c:49             | d1 | start        |     |  0.034157 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' submodule--helper update-module-mode 0 api-configs
21:17:50.541436 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.054575 | process      | windows/ancestry:["sh.exe","explorer.exe"]
21:17:50.542528 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:50.542923 git.c:445                    | d1 | cmd_name     |     |           |              | submodule--helper (_run_dashed_/submodule--helper)
21:17:50.543931 read-cache.c:2315            | d1 | region_enter | r1  |  0.056926 | index        | label:do_read_index .git/index
21:17:50.543931 read-cache.c:2275            | d1 | data         | r1  |  0.057075 | index        | ..read/version:2
21:17:50.543931 read-cache.c:2277            | d1 | data         | r1  |  0.057095 | index        | ..read/cache_nr:89
21:17:50.543931 read-cache.c:2320            | d1 | region_leave | r1  |  0.057108 | index        | label:do_read_index .git/index
21:17:50.543931 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.057631 | process      | windows/memory:{"PageFaultCount":9527,"PeakPagefileUsage":3682304}
21:17:50.543931 git.c:675                    | d1 | exit         |     |  0.057655 |              | code:0
21:17:50.543931 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.057689 |              | code:0
21:17:52.636205 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:52.637203 common-main.c:49             | d1 | start        |     |  0.037411 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' submodule--helper relative-path api-configs ''
21:17:52.658176 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.059121 | process      | windows/ancestry:["sh.exe","explorer.exe"]
21:17:52.659209 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:52.660211 git.c:445                    | d1 | cmd_name     |     |           |              | submodule--helper (_run_dashed_/submodule--helper)
21:17:52.661210 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.061740 | process      | windows/memory:{"PageFaultCount":9494,"PeakPagefileUsage":3686400}
21:17:52.661210 git.c:675                    | d1 | exit         |     |  0.061763 |              | code:0
21:17:52.661210 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.061775 |              | code:0
21:17:58.826520 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:58.827518 common-main.c:49             | d1 | start        |     |  0.033724 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' rev-parse --local-env-vars
21:17:58.850518 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.057204 | process      | windows/ancestry:["sh.exe","(truncated)"]
21:17:58.850518 git.c:445                    | d1 | cmd_name     |     |           |              | rev-parse (_run_dashed_/rev-parse)
21:17:58.850518 ..._win32_process_info.c:166 | d1 | data_json    | r0  |  0.057584 | process      | windows/memory:{"PageFaultCount":9842,"PeakPagefileUsage":3694592}
21:17:58.850518 git.c:675                    | d1 | exit         |     |  0.057607 |              | code:0
21:17:58.850518 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.057619 |              | code:0
21:18:00.947362 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:18:00.948397 common-main.c:49             | d1 | start        |     |  0.036498 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' rev-parse --verify HEAD
21:18:00.968407 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.056906 | process      | windows/ancestry:["sh.exe","(truncated)"]
21:18:00.968407 git.c:445                    | d1 | cmd_name     |     |           |              | rev-parse (_run_dashed_/rev-parse)
21:18:00.970614 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template/api-configs
21:18:00.972622 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.060950 | process      | windows/memory:{"PageFaultCount":9506,"PeakPagefileUsage":3682304}
21:18:00.972622 git.c:675                    | d1 | exit         |     |  0.060976 |              | code:0
21:18:00.972622 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.060989 |              | code:0
21:18:00.982622 run-command.c:990            | d0 | child_exit   |     | 91.261384 |              | [ch0] pid:19900 code:0
21:18:00.982622 ..._win32_process_info.c:166 | d0 | data_json    | r0  | 91.261700 | process      | windows/memory:{"PageFaultCount":6578,"PeakWorkingSetSize":7618560,"PeakPagefileUsage":3678208}
21:18:00.982622 git.c:720                    | d0 | exit         |     | 91.261723 |              | code:0
21:18:00.982622 trace2/tr2_tgt_perf.c:213    | d0 | atexit       |     | 91.261737 |              | code:0

我不确定该怎么做。有人经历过类似的事情并已解决问题吗?有关如何解决问题的任何建议?

有时会输出错误,但无论如何操作都会成功,例如

❯ git submodule update
      0 [main] sh 2038 child_info::sync: wait failed,pid 18572,Win32 error 0
    997 [main] sh 2038 dofork: child -1 - forked process 18572 died unexpectedly,retry 0,exit code 0x8,errno 11
C:/Program Files/Git/mingw64/libexec/git-core\git-submodule: fork: retry: Resource temporarily unavailable
Cloning into 'C:/work/repos/test/api-template/api-configs'...
Submodule path 'api-configs': checked out '1a61134f804c0bd2d6f8a7ccf848136f7bf02309'

如果我在WSL中运行相同的命令,它们几乎立即运行。
我的一些同事报告了相同的问题。他们说Windows重新启动通常可以暂时缓解。就我而言,没有任何帮助。

Windows 10

❯ git version
git version 2.28.0.windows.1

WSL 2(Ubuntu 18.04)

$ git version
git version 2.28.0

解决方法

git submodule主要用shell编写。 Shell脚本通过分叉和执行大量进程来工作,在Windows上这很慢,因为Windows没有有效的方式来分叉进程。

如果有任何进程(例如防病毒程序或其他安全软件)使这些操作变慢,那么它们的速度甚至会变慢。其中一些进程还会监听每个网络连接并进行检查,从而使网络连接也变慢。

您不会在WSL 2中看到速度下降的情况,因为WSL 2本质上是运行真正Linux内核的虚拟机。因此,它在分支和执行过程方面非常快,并且通常不受Windows防病毒或安全软件的监视或拦截。

我的建议是完全卸载所有第三方防病毒或安全软件,重新启动,并改用Windows Defender和Windows防火墙。第三方防病毒软件经常向每个进程中注入代码,这通过将每个进程暴露于同一组不安全的代码中而大大削弱了安全性。此外,它通常会破坏沙盒技术,而沙盒技术可用来防止Chrome等软件的漏洞利用。如果这不可能,那么您可能不得不忍受Windows无法正常运行的事实。

,

解决方法。
对于具有Windows Terminal个用户且启用了pwsh coreWSL 2,您可以将以下功能添加到 Microsoft.PowerShell_profile.ps1 。通常位于C:\Users\<user_name>\Documents\PowerShell

function git() {
    if ($args[0] -eq 'submodule') {
        wsl git $args
    }
    else {
        git.exe $args
    }
}

在CMD或任何其他终端中,运行任何带有submodule前缀的wsl命令:

wsl git submodule update

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...