所以我几天前开始使用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