1. git submodule add git@github.com:deeplovepan/ShareLibrary.git
將ShareLibrary抓下來
2. git commit
commit ShareLibrary和.gitmodules
3. git submodule init
更新.git/config
->
多了
[submodule "ShareLibrary"]
url = git@github.com:deeplovepan/ShareLibrary.git
在UseShareLibraryProject1裡修改submodule ShareLibrary
1. cd ShareLibrary/ShareLibrary, modify ShareLibraryAppDelegate.m
2. git add ShareLibrary/ShareLibraryAppDelegate.m
3. git commit
4. git push
從push只修改到github上的ShareLibrary project
5. 回到UseShareLibraryProject1根目錄, 從根目錄commit和push,
如果才會更新UseShareLibraryProject1採用的submodule版本
6. git add ShareLibrary
7. git commit
8. git push
其它人抓取UseShareLibraryProject1
1. git clone git@github.com:deeplovepan/UseShareLibraryProject1.git
2. git submodule init
更新.git/config,多了submodule的資訊
3. git submodule update
抓取submodule內容
其它人更新UseShareLibraryProject1
1. git pull
更新紀錄的submodule資訊,此時打git submoule,
若開頭有+,表示submodule內容有修改,需更新
ex:
+be295206e07a1eeb6243fa5ee2466c1f6e990e94 ShareLibrary
2. git submodule update
若submodule有更新,抓取submodule內容
只針對UseShareLibraryProject1下的ShareLibrary更新,因為github上的ShareLibrary project有修改
1. 切換至UseShareLibraryProject1下的ShareLibrary
2. git pull origin master
3. 回到UseShareLibraryProject1根目錄
此時打git submodule將出現以下訊息
+27c6861c06fdb3a9c82d9b70d41f6287bc068961 ShareLibrary (remotes/origin/HEAD)
開頭的+表示submodule被更動了
4. git add ShareLibrary
5. git commit
此時再打git submodule,開頭的+不見了
27c6861c06fdb3a9c82d9b70d41f6287bc068961 ShareLibrary
6. git push
沒有留言:
張貼留言