在 git 中将虚拟主机切换到 new_feature 分支的约定是什么?
当使用 git 进行版本控制时,我知道为每个新功能创建一个新分支是惯例。
我在 apache 服务器上用 php 开发 Web 应用程序,但我不知道如何轻松地处理这种开发模式。
这是我的问题:将虚拟主机切换到当前 git 分支文件夹是您正在使用的常见做法吗?
进一步说明
场景: Git 存储库位于 /var/www/ 我有一个 master 分支,它在浏览器中通过 vhost 被识别为 master.localhost ,还有一个开发分支,在浏览器中被识别为develop.localhost 。我正在浏览develop.localhost,并认识到需要开发的新功能。我将存储库分支到 /add-server-side-validation/。要开始在浏览器中测试/查看此内容,我需要添加一个新的虚拟主机,例如 add-server-side-validation.localhost。执行此操作的优雅/传统方法是什么?
When using git for version control, I understand it is convention to create a new branch for each new feature.
I develop web applications in php on an apache server, and I don't know how to painlessly handle this development mode.
And here is my question: Is switching the vhost to the current git branch folder you're working on the common practice?
FURTHER EXPLANATION
Scenario:
Git repo is in /var/www/
I have a master branch which is recognized in the browser through vhost as master.localhost and a develop branch that is recognized as develop.localhost in the browser. I'm browsing around develop.localhost and recognize a new feature that needs to be developed. I branch the repository to /add-server-side-validation/. To begin testing/viewing this in the browser, I need to add a new vhost like add-server-side-validation.localhost. What is the elegant/conventional way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以查看 git-flow 来建立您的分支约定。
You can have a look at git-flow to establish your branching convention.
虽然许多人建议使用功能分支,但这并不是唯一常用的方法。你应该意识到它的存在,但如果有充分的理由说明其他东西可能会更好,则不要觉得受它束缚。
我没有完全遵循 vhost/current git 分支文件夹问题。在网站上使用 git 有多种方法。您可以为每个虚拟主机拥有一个 git 存储库,您可以将 git 存储库的不同子目录作为不同的虚拟主机,是的,您可以将不同的分支作为不同的虚拟主机。
我想说后者相当罕见。仅当虚拟主机非常相似时,您可能希望在虚拟主机之间来回合并(或依次从某个主“模板”分支到每个虚拟主机),不同的分支才有意义。当然,您也可以对多个存储库执行相同的模板操作,其中模板是远程人员可以从中提取和合并的。使用像 gitslave 这样的元存储库系统(或者在本例中较小程度地使用 git-submodules)可能有助于自动化地将每个人从一个公共源合并。
While many people recommend using feature branches, it is hardly the only method in common use. You should be aware that it exists but don't feel bound to it if there are good reasons why something else might be better.
I don't fully follow the vhost/current git branch folder question. There are several ways of using git with web sites. You could have a git repo per vhost, you could have different subdirectories of a git repo being different vhosts, and yes you could have different branches be different vhosts.
I would say the latter is fairly rare. Only if there is great similarity to the vhosts where you might want to merge back and forth between the vhosts (or from some master "template" branch to each vhost in turn) might different branches make sense. Of course, you could also do the same template thing with multiple repositories where template was a remote people could pull and merge from. Using a meta-repository system like gitslave (or to a lesser extent in this case, git-submodules) might help automation of getting everyone merged from a common source.