1. 先進入 Repository 的目錄

2. 新增一個 submodule,指令如下:( git submodule add [repository 位置] [欲放置的位置] )

git submodule add https://github.com/Crisu83/yiistrap.git protected/extensions/bootstrap

3. 查看一下狀態,使用指令如下:

git status

4. 新增更改的資料,使用指令如下:

git add .

5. 新增修改訊息,使用指令如下:

git commit

6. 最後還必須做 init 的動作,.git/config 才會有對應 submodule 的資訊,使用指令如下:

git submodule init

7. push 更新到遠端,如果初次為新 branch,使用指令如下:

git push origin <branch name>

8. 如果是重新安裝 Repository 時需要重新下載 submodule,請使用下列指令:

git submodule init
git submodule update

9. 如果想要移除 submodule,請依照下列步驟移除即可:

   (1) 先移除 submodule 目錄。

   (2) 再修改 .gitmodules,將相關內容移除。

   (3) 再修改 .git/config,將相關內容移除。

   (4) 再將 .git/modules 目錄內相關內容移除。

   (5) 最後再 commit,改變整個 Repository。

git add -A
git commit -m "Removed a submodule."

   (6) 安全起見再做個 sync。

git submodule sync

10. 如果想要檢查 submodule 是否有更新可使用下列指令:

git submodule foreach --recursive git pull origin master
arrow
arrow
    創作者介紹
    創作者 ChouAndy 的頭像
    ChouAndy

    ChouAndy 的學習筆記

    ChouAndy 發表在 痞客邦 留言(0) 人氣()