简体   繁体   English

Git“工作流程”和网站项目中的分支

[英]Git “workflow” and branches in a website project

I know the basics of Git and can run it for my own purposes. 我了解Git的基础知识,并且可以为我自己的目的运行它。 However, the concept of how to make the most of it is a bit vague for me. 但是,如何充分利用它的概念对我来说有点模糊。

Now that I've been using it for a day or two I've been trying figure it out to myself. 现在我已经使用了一两天了,我一直在试图自己解决这个问题。 Perhaps in a website project (lets presume Drupal) there could be branches for: 也许在一个网站项目(假设Drupal)中可能有以下分支:

  • themes 主题
  • modules 模块
  • libraries (perhaps) 库(也许)
  • master (of course) 大师(当然)
  • and perhaps something for testing? 也许是要测试的东西?

This way I could understand that for example a themer could work with own "theme" branch that is eventually merged into master. 通过这种方式,我可以理解,例如,themer可以使用自己的“主题”分支工作,该分支最终合并为master。 Or am I totally lost with this? 还是我完全迷失了这个?

What I'm looking for is concrete examples to understand the workflow? 我正在寻找的是了解工作流程的具体示例? How to make use of Git? 如何使用Git?

If you need to manage themes, modules, libraries etc separately, you can develop them in different branches and then merge into master branch after finishing development each time. 如果需要分别管理主题,模块,库等,则可以在不同的分支中进行开发,然后在每次完成开发后合并到master分支中。

You find refer basic branching and branching workflows in git book for detail examples and understanding. 您可以在git书中找到参考的基本分支分支工作流程,以获取详细的示例和理解。

The workflow you choose really depends on what you need to get out of Git. 您选择的工作流程实际上取决于您要摆脱Git的需求。

In my experience with Drupal, I've found it more helpful to make feature branches . 在使用Drupal的经验中,我发现制作要素分支更为有用。 The workflow is simple: when you start working on a new feature, you start a new branch for it. 工作流程很简单:当您开始使用新功能时,将为其启动一个新分支。 When the feature is done, you merge it into master. 功能完成后,将其合并到母版中。 (This workflow pairs really nicely with Pull Requests. It's helpful when collaborating with other people.) (此工作流程与“拉取请求”非常好地配对。与其他人协作时很有用。)

For example: Let's say you want to build a complex, feature-rich image gallery in your Drupal site. 例如:假设您想在Drupal网站中构建一个功能丰富的复杂图像库。 It's likely that you'll need to.. 您可能需要。

  • ..install a module or two, maybe even a library. ..安装一个或两个模块,甚至一个库。
  • ..make changes to your theme. ..更改主题。
  • ..and implement tests to make sure this feature is well built. ..并执行测试以确保此功能构建良好。

If you use the branches you've suggested, you'd have to do this work across all of them. 如果使用建议的分支,则必须跨所有分支执行此工作。 This would be difficult, to say the least. 至少可以说,这将是困难的。 If you install your modules and build out the basic gallery in one branch, why would you switch to another branch in order to theme it? 如果您在一个分支中安装模块并构建基本库,为什么要切换到另一个分支以为其主题化?

Not to mention, it'd get messy quickly: if you're working on other features at the same time, and/or with other developers, your commits for this feature will be immediately mixed in with all the other work, and it'll be hard to keep track of your progress on each feature. 更不用说,它很快就会变得混乱:如果您同时和/或与其他开发人员一起开发其他功能,则您对该功能的提交将立即与所有其他工作混合在一起,并且很难跟踪每个功能的进度。

Instead of splitting that work over many branches, I'd just start a new branch called "gallery", complete my work there, and merge it into master when it's ready. 与其将工作分解到许多分支上,不如直接启动一个名为“ gallery”的新分支,在那里完成我的工作,并在准备好时将其合并到master中。 Work for each feature stays isolated in its own branch till it's totally done. 每个功能的工作都保持在其自己的分支中,直到完全完成为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM