Jor*_*eno 9 php git github fuelphp
所以我几天前开始使用Git.(派对很晚 - 不要责骂:)).真正开始熟悉基本命令,想法和工作流程.然而,子模块真的让我的大脑有所作为.我正在尝试为FuelPHP的GitHub贡献代码,我可以使用一些指导和提示.
我在终端中运行以下命令:
//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
Run Code Online (Sandbox Code Playgroud)
具体来说,我的问题是:
1.1/develop
子模块中的分支,但*no branch
默认情况下会将其设置为开启状态?我可以修改此行为吗?1.1/master
,1.0/develop
等..).cat .git/config
在超级秀中运行:连同所有子模块......
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git://github.com/fuel/fuel.git`
Run Code Online (Sandbox Code Playgroud)
cat .git config
在核心子模块中运行显示:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git://github.com/fuel/core.git
Run Code Online (Sandbox Code Playgroud)
将这些网址更改为我自己在GitHub上的回购是否明智?无论如何,燃料拒绝推动.如果我执行子模块更新,它们会被覆盖吗?
我也在Fuel的论坛上问过这个问题,但这更像是一个普遍的问题,而且这里有更多的Gitters ......谢谢!
Von*_*onC 11
是的,如" 子模块的真实性质 "中所述
git子模块是对特定提交(SHA1)的引用,而不是分支,因此您始终处于分离模式(与只读用法兼容).
换句话说,git submodule update
检查特定的提交,而不是分支的提示.
该.gitmodule
文件将包含子模块仓库的引用.并且特定的SHA1将作为特殊提交(模式160000)记录在父存储库中.当你git submodule add
是一个新的子模块时,它会记录当前检出其他repo的SHA1(无论它的分支是什么).
如果要进行更改,则必须签出该子模块仓库中的分支(现有分支或新分支:在这两种情况下,您都会将任何新更改推回到该子模块的远程仓库).
另一种选择是git slave.
请参阅2.其中列出的其他分支git branch
是子模块存储库中存在的本地分支,如果您在一个点上执行了一个,则包括每个跟踪分支的一个本地分支git pull
.
因为父级仍然引用子模块的初始SHA1.
但由于您已对其进行了修改,因此需要更新SHA1.
请记住,子模块本身就是一个git repo ...绝对不知道它被用作子模块.因此,必须在父仓库中记录该仓库的新状态(唯一一个跟踪其子模块的状态).
你的第一个git push完全是子模块repo 的内部操作(父repo根本看不到它).
对于父repo,子模块repo是一个"黑盒子",只有一个远程地址和一个SHA1.无论在子模块中做什么都没有对父进程产生任何影响,父进程只会检测子模块树的SHA1的变化.
使用fork可能会有所帮助
请参阅" 更改git子模块的远程存储库 "以更新子模块远程URL.
归档时间: |
|
查看次数: |
4832 次 |
最近记录: |