php – Git子模块工作流建议

前端之家收集整理的这篇文章主要介绍了php – Git子模块工作流建议前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我几天前开始使用 Git. (派对很晚 – 不要责骂:)).真正开始熟悉基本命令,想法和工作流程.然而,子模块真的让我的大脑有所作为.我正在尝试为 FuelPHPGitHub贡献代码,我可以使用一些指导和提示.

我在终端中运行以下命令:

  1. //1: clone the repository from Fuel's github.
  2. git clone git://github.com/fuel/fuel.git
  3.  
  4. //2: move into the main fuel directory
  5. cd fuel
  6.  
  7. //3: initilize the submodules (populate .git/config with submodule data)
  8. git submodule init
  9.  
  10. //4: download the submodules...
  11. git submodule update
  12.  
  13. //5: move into the core directory (which is a submodule).
  14. cd fuel/core
  15.  
  16. //6: change branch from (*no branch) to 1.1/develop
  17. git checkout 1.1/develop
  18.  
  19. //7: open random file in text editor + make some small change (i.e. typo) + save file.
  20. sudo gedit classes/autoloader.PHP
  21.  
  22. //8: add this file to the staging area.
  23. git add classes/autoloader.PHP
  24.  
  25. //9: commit this file under 1.1develop branch.
  26. git commit -m "im committing a submodule"
  27.  
  28. //10: push the new commit to MY (not fuel's) github repo (yes i've renamed the repo).
  29. git push git@github.com:jordanarseno/fuel-core.git
  30.  
  31. //11: changes are reflected on github,looks good.
  32.  
  33. //12: back way out to fuel again. time to push the submodule commit separately.
  34. cd ../../
  35.  
  36. //13: add the fuel/core submodule to the staging area.
  37. git add fuel/core
  38.  
  39. //14: commit the submodule change.
  40. git commit -m "submodule pushed. pushing super now."
  41.  
  42. //15: push the commit to MY (not fuel's) github repo.
  43. git push git@github.com: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并看着我的超级,我做了一个提交.然而,This commit 845de87似乎只是对Fuel的超级而非MY超级的参考.它不应该链接到MY repo而不是它们吗?
>在超级节目中运行cat .git / config:

连同所有子模块……

  1. [remote "origin"]
  2. fetch = +refs/heads/*:refs/remotes/origin/*
  3. url = git://github.com/fuel/fuel.git`

在核心子模块中运行cat .git config显示

  1. [remote "origin"]
  2. fetch = +refs/heads/*:refs/remotes/origin/*
  3. url = git://github.com/fuel/core.git

将这些网址更改为我自己在GitHub上的回购是否明智?无论如何,燃料拒绝推动.如果我执行子模块更新,它们会被覆盖吗?

我在Fuel’s Forums也问过这个问题,但这更像是一个普遍的问题,这里有更多的叮当声……谢谢!

>是的,如“ true nature of submodules”中所述
> git子模块是对特定提交(SHA1)的引用,而不是分支,因此您始终处于分离模式(与只读用法兼容).
换句话说,git子模块更新检出特定的提交,而不是分支的提示.
.gitmodule文件将包含子模块repo的引用.并且特定的SHA1将作为特殊提交(模式160000)记录在父存储库中.当你’git submodule’添加’一个新的子模块时,它会记录当前检出其他repo的SHA1(无论它的分支是什么).
如果要进行更改,则必须签出该子模块仓库中的分支(现有分支或新分支:在这两种情况下,您都会将任何新更改推回到该子模块的远程仓库).
另一种选择是 git slave.
>请参阅2. git分支中列出的其他分支是子模块存储库中存在的本地分支,如果您在一个点执行git pull,则包括每个 tracking branch的一个本地分支.
>因为父级仍然引用子模块的初始SHA1.
但由于您已对其进行了修改,因此需要更新SHA1.
请记住,子模块本身就是一个git repo …绝对不知道它被用作子模块.因此有必要在父回购中记录该回购的新状态(唯一一个跟踪其子模块的状态).
你的第一个git push完全是子模块repo的内部操作(父repo根本看不到它).
对于父repo,子模块repo是一个“黑盒子”,只有一个远程地址和一个SHA1.无论在子模块中做什么都没有对父进程产生任何影响,父进程只会检测子模块树的SHA1的变化.
>使用 forks可能有所帮助
请参阅“ Changing remote repository for a git submodule”以更新子模块远程URL.

猜你在找的PHP相关文章