简体   繁体   中英

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. 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.

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)? Can I not simply use the repo as the web-root?

  • How can I benefit from Branches? Beanstalk recommends deploying from branches. From what I understand, this could mean creating a Production branch, then merging to that branch from the Trunk before deploying? Is there a reason not to simply deploy from the Trunk or just having a webroot in SVN and deploying that? 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? The one main feature I could see if offline commits, but beanstalk even recommends SVN for web development files (html, php, images etc).

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.

--

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. 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. 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!

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. 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.

We branch by release. So the trunk (or master in git) is where the current code resides. 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. 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.

You have really 4 questions

Is it really necessary to use a typical SVN structure (trunk/branches/tags)?

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

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?

Not from Git, but from DVCS as class - yes, it's possible (not a must): and everybody have own reasons

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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