简体   繁体   English

Web开发问题的基本版本控制-单个开发人员。 (SVN / GIT)

[英]Basic version control for web development questions - Single developer. (SVN/GIT)

After much delay, I realize I want to implement a version control system into my workflow for web development. 经过很长时间的延迟后,我意识到我想在我的工作流中实施一个版本控制系统以进行Web开发。 I rarely work with others, so all I need is version control for peace of mind and ability to rollback etc. I also develop from a laptop and desktop at the studio, so I would like to use version control so I can work from different locations and avoid conflicts that emerge from that. 我很少与其他人一起工作,所以我所需要的只是版本控制,以使您安心并具有回滚等功能。我也在工作室的笔记本电脑和台式机上进行开发,因此我想使用版本控制,以便可以在不同的位置工作并避免由此产生的冲突。

I have done a fair bit of research, and most tutorials are rather advanced and seem beyond my needs. 我已经做了相当多的研究,大多数教程都相当先进,似乎超出了我的需求。 Basically, I have decided on an SVN repository from beanstalk and Versions.app to work with it. 基本上,我决定从beanstalk和Versions.app中选择一个SVN存储库来使用它。

However, I have three quick questions I would love to answer before really diving into a solution: 但是,在真正探讨解决方案之前,我想回答三个问题:

  • Is it really necessary to use a typical SVN structure (trunk/branches/tags)? 真的有必要使用典型的SVN结构(主干/分支/标签)吗? Can I not simply use the repo as the web-root? 我可以不简单地将回购用作网络根吗?

  • How can I benefit from Branches? 我如何从分支机构中受益? Beanstalk recommends deploying from branches. Beanstalk建议从分支进行部署。 From what I understand, this could mean creating a Production branch, then merging to that branch from the Trunk before deploying? 据我了解,这可能意味着创建生产分支,然后在部署之前从Trunk合并到该分支? Is there a reason not to simply deploy from the Trunk or just having a webroot in SVN and deploying that? 是否有理由不只是简单地从Trunk进行部署,或者只是在SVN中拥有一个Webroot来进行部署? I suppose I am mainly asking why, as a single developer, I would want to use branches in developing websites? 我想我主要是问为什么作为一个开发人员,我想在开发网站中使用分支机构?

  • Is there any reason I could benefit from GIT? 我可以从GIT中受益吗? The one main feature I could see if offline commits, but beanstalk even recommends SVN for web development files (html, php, images etc). 我可以看到的一项主要功能是脱机提交,但是beantalk甚至建议将SVN用于Web开发文件(html,php,图像等)。

Any help greatly appreciated. 任何帮助,不胜感激。 I've been wanting to use a version control system and develop offline for some time now. 我一直想使用版本控制系统,现在离线开发一段时间。 Hopefully no more editing live servers for me! 希望不再为我编辑实时服务器! I think getting the right workflow down is a time and energy intensive project in the beginning, but so well worth it in the end. 我认为降低正确的工作流程从一开始就是一个耗费时间和精力的项目,但最终还是值得的。

-- -

edit: I am developing mostly wordpress websites, and various EE projects on a reasonably small scale, nothing too intense. 编辑:我主要是在开发wordpress网站和各种EE项目,而且规模相当小,没有什么太激烈的。

-- -

edit: As with everything, working with the system and trying it out is the only way to really get to know it. 编辑:与所有内容一样,使用系统并进行尝试是真正了解它的唯一方法。 In the end, I opted for git. 最后,我选择了git。 I was very happy with being able to commit offline quickly, to do quick branches and merging etc. Then, deployment with capistrano, while initially complex to setup, has been unbelievable. 我对能够快速脱机提交,进行快速分支和合并等感到非常满意。然后,使用capistrano进行部署虽然起初很复杂,但令人难以置信。 My workflow is so fantastically improved now. 我的工作流程现在得到了如此惊人的改善。 I can branch new features quickly and try out new ideas. 我可以快速分支新功能并尝试新的想法。 I will never develop a project again without git! 没有git我将永远不会再开发项目!

I would recommend following the standard structure. 我建议遵循标准结构。 If you do bring other developers on later and they are familiar with the standard structure it'll be that much easier. 如果您以后再邀请其他开发人员来做,并且他们熟悉标准结构,那么会容易得多。

Using tags for releases is very helpful even if you are all alone. 即使您一个人,也使用标签进行发布非常有帮助。 Say you push a version to production and it's botched. 假设您将某个版本推向生产阶段,并且它已被破坏。 If you are always doing things from trunk then you have to look at the date or changesets in order to rollback. 如果您总是从中继干事,那么您必须查看日期或变更集才能回滚。 If you tagged the previous release you can just get the tag and push it without any stress about where one change ends and another begins. 如果您标记了以前的版本,则只需获得标签并进行推送即可,而不必担心更改的结束位置和更改的开始位置。

Creating a tag is trivial and the value you get from it is huge. 创建标签很简单,从标签中获得的价值是巨大的。

I've been on a project with only 2 developers for 18 months and we have not yet created a branch. 我从事只有2个开发人员的项目已经18个月了,我们还没有创建分支。 I suspect you won't need to use them either and could instead deploy from your release tags. 我怀疑您也不需要使用它们,而是可以从发布标签进行部署。

I used SVN for years and still do at times, but I"m slowly switching my team to git. Git is faster, more flexible and allows for local commits. You can work online or offline. With git, you do not need a folder structure for branches and tags--you just say git branch or git tag and it takes a snapshot of your project automatically. There are pros and cons to both svn and git, but overall I think i'm going to like git a bit better. Its also "the new thing" so it may be better for you to learn for when you do eventually work with teams. 我使用SVN已有数年之久,但有时仍会这样做,但是我正在慢慢地将团队切换到git。Git更快,更灵活并且允许本地提交。您可以在线或离线工作。有了git,您不需要文件夹分支和标签的结构-您只要说git branch或git tag,它就会自动拍摄您的项目快照svn和git都有优点和缺点,但总的来说,我想我会更喜欢git它也是“新事物”,因此当您最终与团队合作时,最好向您学习。

We branch by release. 我们按发布分支。 So the trunk (or master in git) is where the current code resides. 因此,主干(或git中的master)是当前代码所在的位置。 Bug fixes and quick changes go there. 修复了错误,并进行了快速更改。 Development that will take longer than a few hours goes in a branch--for new projects, additions, to the website your working on. 耗时超过几个小时的开发将在一个分支中进行-针对您正在工作的网站的新项目,新增项目。 As bug fixes and things go into the trunk, we merge these back into our branch so it has the latest fixes and minor changes. 随着错误修复和事情进入主干,我们将它们合并回我们的分支,以便它具有最新的修复和较小的更改。 When the branch is done, we deploy to that, make it the trunk, and archive the old trunk. 分支完成后,我们将部署到该分支,使其成为主干,并存档旧主干。 We also tag anything we release, so we have a snapshot of what went to production. 我们还标记了发布的所有内容,因此我们可以大致了解生产过程。

I you might look into private repos on github to get started. 我可能会研究github上的私有存储库以开始使用。 Or you can just work locally with git, but its nice to have an offsite server for backups or to pull something down to another machine. 或者,您也可以在本地使用git,但是很高兴拥有一个用于备份的异地服务器或将某些东西拖到另一台机器上。

You have really 4 questions 你真的有四个问题

Is it really necessary to use a typical SVN structure (trunk/branches/tags)? 真的有必要使用典型的SVN结构(主干/分支/标签)吗?

No, it's just more usable and useful and long-time tested workflow: tags are permanent labels, branches allow to solve task separately and hide complexity from final point (in trunk), and don't broke all project while you have something unfinished 不,它只是更实用和有用的,长时间的测试工作流程:标签是永久性标签,分支允许单独解决的任务和隐藏最后一点的复杂性(在主干),并没有打破所有的项目,而你有什么未完成

Can I not simply use the repo as the web-root? 我可以不简单地将回购用作网络根吗?

You can't use repository per se - repository isn't tree in filesystem, identical to your project. 您本身不能使用存储库-存储库不是文件系统中的树,与您的项目相同。 You can try to use working copy as site, but manageable (updated "what" and "when") unversioned snapshot (at least I consider so) is more natural way 您可以尝试使用工作副本作为站点,但是更自然的方式是可管理的(更新“ what”和“ when”)无版本快照(至少我认为是这样)

How can I benefit from Branches? 我如何从分支机构中受益?

Separate line of development, which: 单独的开发线,其中:

  • doesn't interfere with mainline 不会干扰主线
  • allow to solve more one task in parallel with strict separation of changes 允许在严格区分变更的同时解决一项任务

Is there any reason I could benefit from GIT? 我可以从GIT中受益吗?

Not from Git, but from DVCS as class - yes, it's possible (not a must): and everybody have own reasons 不是来自Git,而是来自DVCS类-是的,有可能(并非必须):每个人都有自己的理由

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

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