Php Git子模块工作流建议
所以我几天前开始使用Git。(晚会很晚了-不要责骂:)。真正开始熟悉基本的命令、想法和工作流程。然而,子模块真的让我的大脑陷入了困境。我正在尝试为的贡献代码,我可以使用一些指导和提示 我正在终端中运行以下命令:Php Git子模块工作流建议,php,git,github,fuelphp,Php,Git,Github,Fuelphp,所以我几天前开始使用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: ini
//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 git@github.com: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 git@github.com:jordanarseno/fuel.git
具体而言,我的问题是:
1.1/develop
分支,但默认情况下将我设置为*无分支
?我可以改变这种行为吗1.1/master
,1.0/develope
等)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
将这些url更改为我自己在GitHub上的回购协议是否明智?不管怎样,燃料都不能推动。如果我执行子模块更新,它们会被覆盖吗
我也问过这个问题,但这是一个更一般的问题,这里有更多的吉特人。。。谢谢
换句话说,
git子模块更新
检查特定的提交,而不是分支的尖端。.gitmodule
文件将包含子模块repo的引用。特定的SHA1将作为特殊提交记录在父回购协议中(模式160000)。当您“git子模块”添加一个新的子模块时,它会记录另一个回购当前签出的SHA1(无论其分支如何)。
如果要进行更改,则必须签出该子模块repo中的分支(现有分支或新分支:在这两种情况下,您将把任何新更改推回到该子模块的远程repo)。
另一种选择是
git分支
中列出的其他分支是子模块回购中存在的本地分支,如果您在某一点进行了git拉动
,则每个分支包括一个本地分支但由于您已对其进行了修改,因此需要更新SHA1。
请记住,子模块本身就是git回购。。。完全不知道它是用作子模块的。因此,有必要在父回购中记录该回购的新状态(唯一跟踪其子模块状态的回购)。
您的第一次git推送完全是子模块repo的内部操作(父repo根本看不到它)。
对于父回购,子模块回购是一个“黑匣子”,只有一个远程地址和一个SHA1。子模块内的任何操作都不会对父模块产生影响,父模块只会检测子模块树的SHA1的更改
请参阅“”以更新子模块远程URL
多谢!另一个线程中的优秀帖子。re:2;如何找到子模块引用的特定提交?您说过“必须签出子模块repo中的分支”——它必须是现有分支吗?我可以创造我自己的,从那里开始工作是吗?re:3;在子模块中运行
git branch
,将返回*无分支
和其他分支。我想知道这些“其他人”是从哪里来的。re:4;运行第二次git推送应该已经完成了这一点。。你是说它失败了?re:5,;是的,就是这个主意。fork,然后更改URL。git子模块是否会更新
overwrite?@jordanarsault:我已经编辑了我的答案以回应您的评论: