-
git config --global alias.pull "!git pull && git submodule update --init --recursive"
git config --global alias.pullall "!f(){ git pull "$@" && git submodule update --init --recursive; }; f"
git config --global --unset alias.pullall 取消別名
https://cloud.tencent.com/developer/ask/72181
通過(guò)這種方式,可以在git pull的時(shí)候,自動(dòng)拉到submodule的代碼,就不用每
次都執(zhí)行兩步操作了。
- 對(duì)于submodule的開(kāi)發(fā)者來(lái)說(shuō),需要將submodule的子模塊的代碼,git add commit push到子模塊的遠(yuǎn)程倉(cāng)庫(kù)。
- 而在主項(xiàng)目中,submodule的開(kāi)發(fā)者需要執(zhí)行g(shù)it submodule update --remote 來(lái)獲取子項(xiàng)目的遠(yuǎn)程倉(cāng)庫(kù)代碼,同時(shí)執(zhí)行 add commit push到 主項(xiàng)目的遠(yuǎn)程倉(cāng)庫(kù)。
- 非submodule的開(kāi)發(fā)者(即主項(xiàng)目開(kāi)發(fā)者) 需要保證每次git pull時(shí),同步執(zhí)行g(shù)it submodule update來(lái)拿到主項(xiàng)目中的submodule子模塊的最新代碼,否則可能會(huì)出現(xiàn)舊的submodule版本覆蓋新的 submodule版本的情況。
注意:
- 主項(xiàng)目開(kāi)發(fā)者不需要用到git submodule update --remote 。這個(gè)操作只有submodule的開(kāi)發(fā)者才需要用到。
- 包含submodule的代碼在合并時(shí),比如從develop 合并到 release分支。 切換到release分支時(shí),會(huì)提示FlutterLab有modify,此時(shí)注意不要執(zhí)行add commit push操作,直接合并develop即可。