所以我幾天前開始使用Git。 (晚會很晚 - 不要罵:))。真正開始習慣基本的命令,想法和工作流程。然而,submodules真的讓我的大腦乘坐。我正在嘗試向FuelPHP的GitHub提供代碼,我可以使用一些指導和提示。Git子模塊工作流程建議
我在終端運行以下命令:
//1: clone the repository from Fuel's github.
git clone git://github.com/fuel/fuel.git
//2: move into the main fuel directory
cd fuel
//3: initilize the submodules (populate .git/config with submodule data)
git submodule init
//4: download the submodules...
git submodule update
//5: move into the core directory (which is a submodule).
cd fuel/core
//6: change branch from (*no branch) to 1.1/develop
git checkout 1.1/develop
//7: open random file in text editor + make some small change (i.e. typo) + save file.
sudo gedit classes/autoloader.php
//8: add this file to the staging area.
git add classes/autoloader.php
//9: commit this file under 1.1develop branch.
git commit -m "im committing a submodule"
//10: push the new commit to MY (not fuel's) github repo (yes i've renamed the repo).
git push [email protected]:jordanarseno/fuel-core.git
//11: changes are reflected on github, looks good.
//12: back way out to fuel again. time to push the submodule commit separately.
cd ../../
//13: add the fuel/core submodule to the staging area.
git add fuel/core
//14: commit the submodule change.
git commit -m "submodule pushed. pushing super now."
//15: push the commit to MY (not fuel's) github repo.
git push [email protected]:jordanarseno/fuel.git
具體來說,我的問題是:
- 這是與子模塊工作的正確的工作流程?你會做什麼?
- 爲什麼git將子模塊中的
1.1/develop
分支拉下來,但默認情況下設置爲*no branch
?我可以修改這種行爲嗎? - Fuel子模塊的哪個部分告訴git拉1.1 /開發? 有其他分支(
1.1/master
,1.0/develop
等)。 - 爲什麼我們不能在第11步中稱呼它?子模塊推動正常工作。之後我推超,因爲手冊tells me it's a good idea。事實上,前往GitHub並看着我的超級,提交了一個提交。然而,它似乎只是Fuel的超級參考,而不是我的超級參考。它不應該鏈接到我的回購,而不是他們的?
- 運行在超顯示
cat .git/config
:
隨着所有的子模塊...
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git://github.com/fuel/fuel.git`
核心子模塊運行cat .git config
顯示:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git://github.com/fuel/core.git
難道是明智的更改這些網址爲我自己在GitHub上的回購?無論如何,燃料否認推動。如果我執行子模塊更新,它們是否會被覆蓋?
我也在Fuel's Forums上問過這個問題,但這是更常見的問題,這裏還有更多的Gitters ......謝謝!
非常感謝!優秀的帖子在其他線程。重新:2;如何找到子模塊引用的特定提交?您說過「必須在該子模塊回購中檢出分支」 - 它必須是*現有*分支嗎?我可以創造我自己的,並從那裏工作耶?回覆:3;在子模塊中運行'git branch'會返回'* no branch'等。這些'別人'從哪裏來,是我想知道的。回覆:4;運行第二個git push應該已經完成了這個..你說它失敗了嗎?回覆:5;是的,這是主意。叉,然後更改網址。 git submodule update會覆蓋嗎? – 2012-02-23 12:08:39
@JordanArsenault:我編輯了我的答案以解決您的評論:http://stackoverflow.com/posts/9411932/revisions – VonC 2012-02-23 13:44:33