使用现有的各种 VCS(版本控制系统)来跟踪 Drupal 项目有哪些优点?
我正在尝试为我的 Drupal 工作流程找到最佳的版本控制策略。我每次安装都有多个站点,并且我很确定每个网站都会有一个单独的存储库。据我所知,值得考虑的 VCS 有:
- SVN
- Bazaar (bzr)
- Git
- Mercurial (hg)
我知道它们之间的一般比较,但想了解它们对于 Drupal 的优点/缺点。如果您正在(或已经使用)Drupal 中的任何一个:
- 您的设置是什么?
- 您选择的 VCS 是否适合管理 Drupal 项目?
- 什么不可以?
I'm trying to find the best version control strategy for my workflow with Drupal. I have multiple sites per install and I'm pretty sure I'll have a separate repository for each website. As far as I know, the VCSs worth considering are:
- SVN
- Bazaar (bzr)
- Git
- Mercurial (hg)
I know how these compare to each other in general, but want to learn their merits/demerits for Drupal. If you're using (or have used) any of these for Drupal:
- What is your setup?
- What about the VCS you chose works well for managing Drupal projects?
- What doesn't?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
另一个颠覆设置在这里。
基本设置是:
优点:
缺点:
结论:
只要您只需要管理少数项目/站点,这可能不会有效,并且您可能会更好地提交和维护整个设置(核心、贡献和自定义内容)合并在一个分支内。
但我可以保证,一旦您必须并行管理 10++ 个项目(一些在 5.x 上,一些在 6.x 上,所有项目都处于不同的更新和/或自定义级别,通常重用相同的自定义),能够分辨到底在哪里使用什么代码是一个巨大的缓解!
PS:重读我的讲道,很明显它并没有真正解决你关于不同 VCS 相对优点的问题 - 对此感到抱歉,但也许它无论如何都有帮助;)
Another subversion setup here.
Basic setup is:
Pros:
Cons:
Conclusion:
As long as you have to manage only a handful of projects/sites, this might not be effective, and you might be better of committing and maintaining the whole setup (core, contrib and custom stuff) combined within one branch.
But I can assure that once you have to manage 10++ projects in parallel (some on 5.x, some on 6.x, all at different update and/or customization levels, often reusing the same customizations), being able to tell what code gets used where exactly is a huge relieve!
PS: Rereading my sermon, it is somewhat obvious that it does not really address your question regarding the merits of different VCS as compared to each other - sorry for that, but maybe it helps anyway ;)
我们的设置基于 Subversion。我们只有很少的人(少于 4 人)可以对网站进行更改,我们考虑过像 Git 这样的 DVCS,但得出的结论是它太过分了。
在提交任何更改之前,我们使用 SimpleTest 测试我们的模块,如果我们添加了一个,我们会进行新的测试未涵盖的功能。在我看来,提交更改之前的测试步骤比您最终决定使用哪个版本控制程序重要得多。
在处理这些程序时,您应该记住的另一件重要的事情是,您不应该只是定期检查来更新生产站点上的代码。这将留下隐藏的 .svn 或其他可能包含密码和其他敏感数据的目录。
相反,您应该从sites/all/modules 目录中删除该模块,然后删除
svn export
以获得最新代码的干净版本。版本控制是管理站点系统的一部分,请务必通过定期备份数据库本身(与 svn 提交同步是理想的)以及存储 CCK 的定义来跟踪存储在数据库中的站点配置如果可以的话,将内容类型添加到您的主站点外部。您可以导入和导出内容类型和视图,以便在需要重建站点配置时它们不会卡在数据库中。
部署 模块是另一件需要考虑的事情,具体取决于您的工作流程。
Our setup is based on Subversion. We have a smallish (less than 4) number of people who can make changes to the site, and we considered a DVCS like Git but concluded it was overkill.
We test our module with SimpleTest before committing any changes, and we make new tests if we've added a feature that isn't covered. In my opinion this step of testing before you commit a change is far more important than which version control program you decide to go with in the end.
Another important thing you should keep in mind when dealing with these programs is that you shouldn't just do a regular checkout to update the code on your production site. This will leave hidden .svn or other directories around which can contain passwords and other sensitive data.
Instead you should delete the module from your sites/all/modules directory and so an
svn export
to get a clean version of the latest code.Version control is one part of the system for managing sites, be sure to also keep track of your site's configuration stored in the database, by backing up the database itself regularly (synched with svn commits would be ideal) and also by storing definitions of CCK content types externally to your main site if you can. You can import and export content types and Views so that they aren't stuck in your database if you need to rebuild your site's configuration.
The Deployment module is another thing to consider depending on your workflow.
自从我提出这个问题以来,Drupal 方面出现了相当令人惊讶的发展:他们有 有点可能选择 CVS 的替代品!考虑到大规模的社区支持以及对分布式 VCS 的需求,他们可能会转向 git。
由于文档和跨平台支持较差(与 Bazaar 和 Mercurial 相比),我之前曾考虑并放弃 git,但从那时起,它们在这两个领域都取得了巨大的进步,无论您的情况如何,它现在似乎都是一个非常好的选择。
因此,如果您正在考虑为“核心”或 contrib 模块做出贡献,或者为社区编写自己的模块,我强烈建议使用 git,因为它将在 Drupal 社区中获得最多的支持和用户。因此,即使您只是跟踪自己的网站,它也可能是一个不错的选择。
Since I asked this question there has been a rather surprising development on the Drupal front: They have sort of maybe chosen a replacement for CVS! Citing massive community support, and the need for a distributed VCS, they will probably be moving to git.
I have previously considered and passed over git due to worse documentation and cross-platform support (compared to Bazaar and Mercurial), but since then they have improved massively in both areas and it seems it's now a really good option whatever your circumstances.
Therefore, if you are considering contributing to "core" or contrib modules, or writing your own module for the community, I would strongly recommend using git as it will have the most support and users in the Drupal community going forward. For that reason it's probably a good choice even if you're just tracking your own sites.
与任何其他通用软件源相比,Drupal 没有任何特定要求。
下面是 Git/Mercurial 与 Subversion 的对比:
.gitignore
可以告诉您要忽略的所有文件.svn
文件夹(这会强制使用慢速导出功能或自定义批处理来删除它们)git add . && git commit -m“我的第一次提交”
显然我偏向于 Git 和 Mercurial。两者都是较新的。我个人更喜欢 Git,因为:
不过你应该注意到 Mercurial em> 最近引起了 Google 的关注(对于 Google 代码),并且学习起来比较简单。您可以从 http://progit.org/book/ 学习 Git (前三章应该足够了)。
至于项目文件夹结构,我建议你查找其他答案。记住您的目标(例如:测试、在各种机器上快速部署...),并备份您的存储库。这意味着将项目文件夹复制到 Git/Mercurial 的远程位置,并复制 Subversion 服务器存储库以实现 Subversion。除此之外,所有这些都具有允许您在提交之前运行测试的钩子,并且它们具有错误跟踪系统的接口。
最重要但并非最不重要的一点是,如果您在项目中在版本控制下使用其他库,请考虑这一点! Git 和 Mercurial 允许跟踪 Subversion 存储库(通过
git-svn
),而不是相反。 Mercurial 还可以跟踪Git 存储库,而不是相反(还)。跟踪远程存储库允许您获取最新版本以及您将使用的远程源代码的更改日志。它还允许您修改它。Drupal doesn't have any specific requirement compared to any other general software source.
Here is Git/Mercurial vs. Subversion:
.gitignore
allows to tell all files you'd like to ignore.svn
folder in each of your folders (which forces to use the slow export function or a custom batch to remove them)git add . && git commit -m "My first commit"
Clearly I'm biased toward Git and Mercurial. Both are more recent. I personally prefer Git because:
Still you should note that Mercurial got Google's attention recently (for Google Code) and it's somewhat simpler to learn. You can learn Git from http://progit.org/book/ (the first 3 chapters should be enough).
As for the project folder structure, I suggest you look-up other answers. Keep in mind your goal (ex: testing, quick deployment on various machines...), and backup your repository. That means copying your project folder to a remote location for Git/Mercurial, and copying your Subversion server repository for Subversion. Outside of that, all have hooks allowing you to run tests before committing, and they have interfaces to bug tracking systems.
Least but not least, if you use other libraries under version control in your project, consider that! Git and Mercurial allow to track a Subversion repository (via
git-svn
), not the opposite. Mercurial can also track a Git repository, not the opposite (yet). Tracking a remote repository allows your to get the latest version with a change log of remote source code you'll be using. It also allows you to modify it.如果你有很多团队成员,我会投票给 git。虽然 Git 文档仍然很糟糕 - 免费的 http://progit.org 书籍和http://gitcasts.com 使学习如何使用变得容易。由于它是如此独立,因此可以轻松地随时随地处理项目(相对于 SVN)。
我是作为一个 SVN 经验比 git 经验丰富的人这么说的。开发正在转向 git,远离 SVN 等中央系统。
就我个人而言,我喜欢它的一点是在站点的不同测试版本(使用分支)之间来回跳转是多么容易。
I would vote for git if you have many team members. While the Git documentation is still terrible - the free http://progit.org book and http://gitcasts.com make it easy to learn how to use. Since it is so independent it makes it easy to work on projects anywhere at anytime (vs SVN).
And I'm saying this as a guy with more SVN experience than git. Development is moving towards git and away from central systems like SVN.
Personally, the thing I like about it is how easy it is to jump back and forth through different test versions of your site (using branches).