问题描述
在拉取仓库的时候发现了新东西。
仓库中有两个文件夹提示@
点击之后,发现跳转到了另一个仓库 ,原来这是仓库的子模块,第一次见,也就是仓库中包含了其他的的仓库,就是这么简单的原理。
但是在拉取仓库以后发现这两个子模块下是空的。
原来拉去子模块要使用git clone --recursive
要是使用图形化工具,小乌龟之类的,拉取的时候记得勾上recursive
但是这还没完。包含子模块一起拉取的时候又报了错。
git.exe clone --progress --recursive -v "https://gitee.com/hair-monk/mysql_tpcc_2024.git" "C:\Users\ybac2\Desktop\mysql_tpcc\mysql_tpcc_2024"
Cloning into 'C:\Users\ybac2\Desktop\mysql_tpcc\mysql_tpcc_2024'...
POST git-upload-pack (185 bytes)
POST git-upload-pack (212 bytes)
remote: Enumerating objects: 37, done.
remote: Counting objects: 100% (37/37), done.
remote: Compressing objects: 100% (26/26), done.
remote: Total 37 (delta 8), reused 36 (delta 8), pack-reused 0
Receiving objects: 100% (37/37), 10.57 MiB | 2.36 MiB/s, done.
Resolving deltas: 100% (8/8), done.
Submodule 'benchmarksql' (git@gitee.com:polardb-tianchi/benchmarksql.git) registered for path 'benchmarksql'
Submodule 'mysql-server' (git@gitee.com:polardb-tianchi/mysql-server.git) registered for path 'mysql-server'
Cloning into 'C:/Users/ybac2/Desktop/mysql_tpcc/mysql_tpcc_2024/benchmarksql'...
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@gitee.com:polardb-tianchi/benchmarksql.git' into submodule path 'C:/Users/ybac2/Desktop/mysql_tpcc/mysql_tpcc_2024/benchmarksql' failed
Failed to clone 'benchmarksql'. Retry scheduled
Cloning into 'C:/Users/ybac2/Desktop/mysql_tpcc/mysql_tpcc_2024/mysql-server'...
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@gitee.com:polardb-tianchi/mysql-server.git' into submodule path 'C:/Users/ybac2/Desktop/mysql_tpcc/mysql_tpcc_2024/mysql-server' failed
Failed to clone 'mysql-server'. Retry scheduled
Cloning into 'C:/Users/ybac2/Desktop/mysql_tpcc/mysql_tpcc_2024/benchmarksql'...
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@gitee.com:polardb-tianchi/benchmarksql.git' into submodule path 'C:/Users/ybac2/Desktop/mysql_tpcc/mysql_tpcc_2024/benchmarksql' failed
Failed to clone 'benchmarksql' a second time, aborting
git did not exit cleanly (exit code 1) (18687 ms @ 2024/10/12 17:38:15)
报错说我权限不够,我以为是SSH权限的问题,把自己的SSH重新在gittee上配置了一遍,发现还是报错。
如果问题一样的话,可以直接看思路二,直接的解决办法,思路一是曲线解决了问题,发现了问题的本质,才有了思路二。
思路一
这时候看到有篇博客说要修改子模块的拉取的路径,把git url,替换为https方式!
打开我的.git下的config文件
发现里面的子模块还真是git的拉取方式。
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[submodule]
active = .
[remote "origin"]
url = https://gitee.com/hair-monk/mysql_tpcc_2024.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[submodule "benchmarksql"]
url = git@gitee.com:polardb-tianchi/benchmarksql.git
[submodule "mysql-server"]
url = git@gitee.com:polardb-tianchi/mysql-server.git
现在手动去找到两个仓库的地址,并且把git的配置文件修改成https方式。
然后把这两个子模块的文件加删了,重新执行it submodule update –init
然后就可以拉下来了
思路二:
我们出问题的原因就是因为子模块和仓库的拉取方式不一样导致的,那我们刚刚也已经看了git的配置文件,配置文件中明确了子模块的拉取方式是git,而我刚开始拉取仓库的时候的拉取方式采用的Https的方式,所以才报错了,那我们拉取仓库的时候,直接使用git拉取, 让仓库和子模块的拉取方式保持一致不就行了?
就是这么简单,重新拉一下就好了:
git clone --recursive git@gitee.com:hair-monk/mysql_tpcc_2024.git
我刚开始复制地址的时候没看清,选择了Https方式的git clone没想到也成功了,如下指令
git clone --recursive https://gitee.com/hair-monk/mysql_tpcc_2024.git
对此我不得不怀疑是因为使用图形化界面的原因了,以后还是少用图形化界面,都是问题。