我有一个包含多个子模块的Git存储库。我已经尝试删除并添加有问题的子模块(scopatz的nanorc),但是在删除和重新添加后,错误仍然存在。当我将存储库克隆到新位置时,我会使用git submodule update --init --recursive
自动更新,但是只对这个子模块失败...
下面是带有GIT_TRACE=2
的相关命令输出:
23:01:26.918691 run-command.c:1569 run_processes_parallel: preparing to run up to 1 tasks
23:01:26.933567 run-command.c:1601 run_processes_parallel: done
23:01:26.934373 run-command.c:646 trace: run_command: git gc --auto
23:01:26.966805 git.c:344 trace: built-in: git gc --auto
23:01:26.991059 git.c:344 trace: built-in: git rev-parse --local-env-vars
23:01:27.015684 git.c:344 trace: built-in: git rev-parse --local-env-vars
23:01:27.032282 git.c:344 trace: built-in: git symbolic-ref -q HEAD
23:01:27.053948 git.c:344 trace: built-in: git config --get branch.master.remote
23:01:27.073636 git.c:344 trace: built-in: git fetch origin 151d94a8754b0a612315fc191c5373cc0055c13d
23:01:27.079657 run-command.c:646 trace: run_command: git-remote-https origin https://github.com/scopatz/nanorc.git
23:01:28.441725 run-command.c:646 trace: run_command: git rev-list --objects --stdin --not --all --quiet
23:01:28.452267 run-command.c:646 trace: run_command: git fetch-pack --stateless-rpc --stdin --lock-pack --thin https://github.com/scopatz/nanorc.git/
23:01:28.467757 git.c:344 trace: built-in: git fetch-pack --stateless-rpc --stdin --lock-pack --thin https://github.com/scopatz/nanorc.git/
fatal: remote error: upload-pack: not our ref 151d94a8754b0a612315fc191c5373cc0055c13d
fatal: The remote end hung up unexpectedly
Fetched in submodule path 'submodules/nano', but it did not contain 151d94a8754b0a612315fc191c5373cc0055c13d. Direct fetching of that commit failed.
希望这里有人可以帮忙,我现在有点迷茫。=== 编辑:解决步骤如下 ===
cd {submodule path}
git reset --hard origin/master
cd -
git clean -n
git add {submodule path}
git commit
git submodule update --init --recursive
没有错误,太棒了。