Created
July 19, 2013 04:09
-
-
Save sivagao/6035118 to your computer and use it in GitHub Desktop.
git submodule使用
http://josephj.com/entry.php?id=342
剛剛從 SVN 或 CVS 等 Client-Server 架構的版本控制系統切換到 Git 時,可能會有這個想法:「能不能只取得一部分的程式碼、而非整個 Repository?」因為在 SVN/CVS 可以針對 Repository 中的某個目錄 checkout,不需要是整個 Repository、甚至還可以用 SVN Externals 達到不同角色 (視覺、前端、後端)checkout 不同 File Layout Git Submodule 可以輕易地將別人的 git 掛入到你目前 git 的任何位置。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Example | |
目前本機有一個 josephj.git、在 /home/josephj/www 下,而我需要將 javascript platform 放到 /home/josephj/www/static/ | |
cd /home/josephi/www | |
git submodule add <git addr> static/platform | |
论坛 | |
在父亲项目下, 删除目录(template/weekxx, static/) | |
git submodule add <> template/weekxx | |
git add .gitmodules static/platform | |
git commit -m "add submodule into version control" | |
// 这样.git/config下才会有对应submodule的信息 | |
git submodule init | |
// 在服务器在父亲项目下 | |
// 要先进入子项目中更新 | |
cd static/platform | |
git pull origin master | |
// cd ../.. | |
git commit -m "static/platform submodule updated" | |
git submodule update: | |
在 init 完有新的 submodule commit id 後就可以做了,會把所有相關檔案拉下來。若其他人更新 submodule 造成你拿到新的 commit id 時,你可以直接用 git submodule update 做更新即可、不需要做任何 add 或 commit 的動作! | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment