先記錄一下

Submodule 作用:
把 Lib 版本庫 崁入 Project 版本庫
( Project 版本庫 -> 父版本庫 )
Submodule Add:
Lib 版本庫 clone 成 Project 版本庫 的 Submodule
( Lib 以 submodule 的型式 被 Project 使用 )
在 父版本庫 中 , 可以把 submodule 視為一大塊"檔案"
==============================================================
以下示範加入 submodule 操作
Lib: 準備被加入為 submodule 的 git 版本庫
Project: 準備加入 Lib 為 submodule 的 git 父版本庫

在 父版本庫 , TortoiseGit -> Submodule Add...

填入 Path
(不能先建好該資料夾)
猜測理由: 該資料夾是專用的資料夾, 不能跟其它受版控檔案及資料夾混用
(雖然 git 不版控資料夾)

按 OK
會出現錯誤 LF 錯誤 (似乎可以不理它)

首先, 檢查父版本庫的版本路徑下是否產生 .gitmodules

再檢查剛剛填入的 Path 下是否有 submodule 了
( Lib 資料夾: 含 Working Tree 以及 一個 .git 檔案, 注意: 不是 .git 資料夾 )

先 commit .gitmodule 和 submodule 的資料夾
( 把 submodule 整個資料夾下所有東西視為一大塊 "檔案" )
( 如果因為 .gitmodule 的 EOL 為 LF 而不能 commit
可以進 Settings 將 SafeCrlf 改為 false )
刪掉 .gitmodule, 再 Revert 回來
( 目的: 將 LF 全部改為 CRLF ; Settings 的 AutoCrlf 需勾選 )

可以進 Settings 將 SafeCrlf 改為 false )
刪掉 .gitmodule, 再 Revert 回來
( 目的: 將 LF 全部改為 CRLF ; Settings 的 AutoCrlf 需勾選 )

進入 Git Bash 下指令:
git submodule status
沒有留言:
張貼留言