發現之前的介紹有許多謬誤,再重新發表一次。

在這裡有很清楚的描寫:Git Submodule Tutorial

如何 Check out 內含 submodule 的 repository (Ex: super)

#git clone {REPO_PATH}/super
#cd super
#git submodule update --init (這行會對 .git/config 補上 submodule 的敍述,同時更新所有的 submodule)

在 super repo 底下更新所有的 submodule repo

# (在 super 根目錄下)
#git pull (會發現有些 submodule 變成 modified)
#git submodule update --init

修改 submodule 的 commit push 流程(Ex: sub-repo)

#(在 sub-repo 下修修改改後)
#git commit -m 'commit log'
#git push
#(回到 super 的根目錄)
#git commit -a -m 'submodule modified'
#git push

要注意的是,使用 git submodule update --init 所 checkout 的 submodule branch 為一個 no name branch. 所以要直接在有 super repo 底下的 submodule 裡做 commit 的話,要先切到可以提交 push 的 branch.(Ex: git checkout master)

在 super repo 下新增 submodule repo: sub-repo2

#(在 super 根目錄下)
#git submodule add {REPO_PATH}/sub-repo2 sub-repo2 (後面的 sub-repo2 可以自訂為你想要的 path name,比方說 loli
#git commit -m 'add submodule sub-repo2'
#git push
#git submodule init sub-repo2 (這行會對 .git/config 補上 submodule 的敍述)

 

刪除 submodule 原文寫的很清楚了,這裡就不再提。

 

arrow
arrow
    全站熱搜

    沒力小僧 發表在 痞客邦 留言(0) 人氣()