解決子模組在對應上的問題

因為之前的2016fallcadp_hw倉儲少複製了一些東西,刪除舊的倉儲後,重新做一個和之前倉儲同名的2016fallcadp_hw倉儲,但是在小組倉儲所連結的子模組,抓不到新倉儲連結,所以我們需要重新加入一次組員倉儲的資料

以為只要再輸入一次指令就可以讓程式抓最新的子模組近來

Y:\tmp\2016fallcadp_bg6>git submodule add -b gh-pages https://github.com/40423216/2016fallcadp_hw.git 40423216
'40423216' already exists in the index

但是程式告訴我們40423216的子模組已經在裡面,所以在試著用git rm 40423216 -f 來刪除存放該子模組資料的資料夾,然後再git submodule add的一次組員倉儲的資料

Y:\tmp\2016fallcadp_bg6>git submodule add -b gh-pages https://github.com/40423216/2016fallcadp_hw.git 40423216
A git directory for '40423216' is found locally with remote(s):
  origin        https://github.com/40423216/2016fallcadp_hw.git
If you want to reuse this local git directory instead of cloning again from
  https://github.com/40423216/2016fallcadp_hw.git
use the '--force' option. If the local git directory is not the correct repo
or you are unsure what this means choose another name with the '--name' option.

程式告訴我們還有資料沒刪除乾淨,於是我們再執行一次刪除的指令

Y:\tmp\2016fallcadp_bg6>git rm 40423216 -f
fatal: pathspec '40423216' did not match any files

然而程式說找不到任何有關該名稱的文件資料,後來我們發現submodule內的設定並沒有也因此刪除,要刪除submodule的設定有兩個方法

解決方法一

從SciTE打開,在2016fallcadp_bg6資料夾內的.gitmodules檔案,把該組員的子模組設定刪除後就可以存檔

[submodule "40423206"]
    path = 40423206
    url = https://github.com/40423206/2016fallcadp_hw.git
    branch = gh-pages
[submodule "40423224"]
    path = 40423224
    url = https://github.com/40423224/2016fallcadp_hw.git
    branch = gh-pages
[submodule "2016fallcadp_hw"]
    path = 2016fallcadp_hw
    url = https://github.com/40423226/2016fallcadp_hw.git
    branch = gh-pages
[submodule "40423229"]
    path = 40423229
    url = https://github.com/40423229/2016fallcadp_hw.git
    branch = gh-pages
[submodule "40423214"]
    path = 40423214
    url = https://github.com/40423214/2016fallcadp_hw.git
    branch = gh-pages
[submodule "40423216"]
    path = 40423216
    url = https://github.com/40423216/2016fallcadp_hw.git
    branch = gh-pages

如果有打下面的指令,把各組員子模組的資料抓近來,記得要把2016fallcadp_bg6\.git\modules裡該組員的隱藏資料夾刪掉

git submodule update --init --recursive

就可以重新執行指令,把組員的子模組加進來

git submodule add -b gh-pages https://github.com/40423216/2016fallcadp_hw.git 40423216

解決方法二

直接依序執行以下的指令

git submodule deinit asubmodule    
git rm asubmodule
# Note: asubmodule (no trailing slash)
# or, if you want to leave it in your working tree
git rm --cached asubmodule

但是在2016fallcadp_bg6\.git\modules裡的隱藏資料夾,還是需要自己動手刪除