此问题已在此处有答案:
Git update submodules recursively(7个回答)
5天前关闭。
首先,我请求不要因为我使用git而受到评判。..这可能不是最佳的,但到目前为止它已经工作。目前我正在用它在我的设备之间同步我所有的大学项目。对于一些课程,我也有子模块,因为这些是我与其他人合作的项目。到目前为止,使用git子模块似乎工作得很好,但是对于我添加的最后两个子模块,我可以推送更改没有问题,但是当拉取时,包含子模块的目录完全是空的,甚至没有。git文件。下面是我尝试过的一些方法和结果:
PS D:\University> git pull --recurse-submodules
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 10 (delta 5), reused 8 (delta 3), pack-reused 0
Unpacking objects: 100% (10/10), 1.04 KiB | 1024 bytes/s, done.
From https://github.com/**********/University
0e65e10f..c47ea81b master -> origin/master
Fetching submodule Semantics and Rewriting/PokeBattles_project
Fetching submodule Year 2/New Devices Lab/smart-closet
Fetching submodule Year 2/New Devices Lab/smart-shop/final project
From https://github.com/**********/Smart-Shop-Project
ab09d5a..3304c39 master -> origin/master
* [new branch] dependabot/npm_and_yarn/mongoose-7.0.4 -> origin/dependabot/npm_and_yarn/mongoose-7.0.4
* [new branch] dependabot/npm_and_yarn/nodemon-2.0.22 -> origin/dependabot/npm_and_yarn/nodemon-2.0.22
warning: unable to rmdir 'Semantics and Rewriting/PokeBattles_project': Directory not empty
Updating 0e65e10f..c47ea81b
Fast-forward
.gitmodules | 7 +++++--
Human-Computer Interaction/Project/HCI-Project | 1 +
.../{PokeBattles_project => PokeBattle-Project} | 0
3 files changed, 6 insertions(+), 2 deletions(-)
create mode 160000 Human-Computer Interaction/Project/HCI-Project
rename Semantics and Rewriting/{PokeBattles_project => PokeBattle-Project} (100%)
PS D:\University> git submodule update --remote
Submodule path 'Year 2/New Devices Lab/smart-shop/final project': checked out '3304c398f204debcafa8e37dd89e038feeb345d2'
PS D:\University> git submodule update --recursive --checkout --remote
PS D:\University> git submodule foreach git pull origin main
Entering 'Year 2/New Devices Lab/smart-closet'
fatal: couldn't find remote ref main
fatal: run_command returned non-zero status for Year 2/New Devices Lab/smart-closet
.
正如你所看到的,我已经尝试了多种方法,我已经看到浮动。这两个子模块是“HCI项目”和“Pokebattle项目”。HCI项目包含一个完整的Unity项目以及一个自述文件和一个。gitignore,另一个只是一个自述。屁股你可以看到这里,他们是完全空的,甚至没有一个。git文件。正因为这个原因,如果我再次尝试git pull --recurse-submodules
,git似乎甚至不会尝试从这些仓库中拉取:
PS D:\University> git pull --recurse-submodules
Fetching submodule Year 2/New Devices Lab/smart-closet
Fetching submodule Year 2/New Devices Lab/smart-shop/final project
Fetching submodule Year 2/New Devices Lab/smart-shop/login system
Fetching submodule Year 2/New Devices Lab/smart-shop/mongo_db-app
Already up to date.
Submodule path 'Year 2/New Devices Lab/smart-shop/final project': checked out 'eda28e13dc7cadeef8539fe0b2e3d6a2fe28cd0b'
PS D:\University> cd '.\Human-Computer Interaction\Project\HCI-Project\'
PS D:\University\Human-Computer Interaction\Project\HCI-Project> ls
PS D:\University\Human-Computer Interaction\Project\HCI-Project> cd '..\..\..\Semantics and Rewriting\PokeBattle-Project\'
PS D:\University\Semantics and Rewriting\PokeBattle-Project> ls
PS D:\University\Semantics and Rewriting\PokeBattle-Project> cd ../../
PS D:\University> cat .gitmodules
[submodule "smart-closet"]
path = smart-closet
url = ../smart-closet/
[submodule "Year 2/New Devices Lab/smart-closet"]
path = Year 2/New Devices Lab/smart-closet
url = ../smart-closet
[submodule "Year 2/New Devices Lab/smart-shop/final project"]
path = Year 2/New Devices Lab/smart-shop/final project
url = ../Smart-Shop-Project
[submodule "Year 2/New Devices Lab/smart-shop/login system"]
path = Year 2/New Devices Lab/smart-shop/login system
url = ../Basic-Node.js-Login-System/
[submodule "Year 2/New Devices Lab/smart-shop/mongo_db-app"]
path = Year 2/New Devices Lab/smart-shop/mongo_db-app
url = ../Mybrary/
[submodule "Semantics and Rewriting/PokeBattle-Project"]
path = Semantics and Rewriting/PokeBattle-Project
url = https://github.com/DragosSpiridon/PokeBattle-Project.git
[submodule "Human-Computer Interaction/Project/HCI-Project"]
path = Human-Computer Interaction/Project/HCI-Project
url = https://github.com/DragosSpiridon/HCI-Project.git
您还可以看到,子模块在.gitmodules
文件中定义。你知道发生了什么事,我该怎么解决吗?
1条答案
按热度按时间3phpmpom1#
Peter Krebs提供的链接包含了我需要的答案。更具体地说,我不得不使用
git submodule update --init --recursive
。我不知道子模块在克隆时也必须初始化。注意:这个命令只执行了第一次提交(我想),之后我还必须在子模块目录中执行另一个
git pull origin main
。