vault backup: 2025-03-04 11:17:00
This commit is contained in:
27
22.01. 軟體工具、設定/git/submodule.md
Normal file
27
22.01. 軟體工具、設定/git/submodule.md
Normal file
@@ -0,0 +1,27 @@
|
||||
## 建立 Git Submodule
|
||||
```
|
||||
git submodule add <repository> [<local_path>]
|
||||
```
|
||||
新增之後,用 git status 會發現多了兩個東西需要 commit:
|
||||
![[20220608152709_git_submodule.png|450]]
|
||||
|
||||
第一個檔案 .gitmodules,裡面紀錄 submodule 的對應關係,內容大概像這樣:
|
||||
```
|
||||
[submodule "RobotRunQA"]
|
||||
path = RobotRunQA
|
||||
url = git@github.com-logi:JuiwenHsu/RobotRunQA.git
|
||||
```
|
||||
|
||||
接下來剩3個步驟:
|
||||
1. 提交 `.gitmodule`:`git add .gitmodule ; git push origin master`
|
||||
2. 跟git說我們有新增一個submodule:`git submodule init`
|
||||
3. 把submodule pull下來:`git submodule update`
|
||||
|
||||
## Clone repository and submodule
|
||||
當clone一個有submodule的repo的時候,我們還需要 `git submodule init` 跟 `git submodule update` ,例如:
|
||||
```
|
||||
git clone https://xxx/xxx.git
|
||||
cd xxx
|
||||
git submodule init
|
||||
git submodule update
|
||||
```
|
||||
Reference in New Issue
Block a user