2

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!

waffl
  • 5,179
  • 10
  • 73
  • 123
  • Have you looked at these questions? http://stackoverflow.com/questions/2557283/why-use-branches-in-svn http://stackoverflow.com/questions/111031/comparison-between-centralized-and-distributed-version-control-systems – jlemos Feb 23 '12 at 17:07
  • Almost a duplicate of [Is it worth going to Git from SVN for a single developer?](http://stackoverflow.com/questions/927515/is-it-worth-going-to-git-from-svn-for-a-single-developer) - but the answers there are applicable. – Abizern Feb 23 '12 at 17:17

3 Answers3

2

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.

digitaljoel
  • 26,265
  • 15
  • 89
  • 115
  • Ok, definitely important to look into tags, thank you! I had a similar question as below, do you simply keep all your web root files in the trunk directory? – waffl Feb 23 '12 at 17:57
  • We do all active development on the trunk, yes. When I want to create a release I create the tag, then I can just do an svn export on the tag to get everything without the .svn directories. I tar that up, transfer it to my webserver and explode it and I'm good to go. – digitaljoel Feb 23 '12 at 18:44
1

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.

fregas
  • 3,192
  • 3
  • 25
  • 41
  • Ok. This sounds like a logical workflow. So do you basically keep all the contents of say a web root folder in the trunk folder? Then, you might create a branch like 2.0 and work on significant new features in that branch while fixing small things in the trunk? Do you mean you deploy the branch? How do you make it the trunk, and how do you archive the old trunk? I suppose I'm confused as once a branch has finished development, is it not just remerged into the trunk then deleted? – waffl Feb 23 '12 at 17:56
  • You don't have to archive the "old" trunk. Even after you re-merge a branch, the old trunk is still there. If you need it, you simply pull an old revision. You'll typically set a tag on any checkpoint that you may need to refer to again in the future (it makes it easier to find and checkout), such as released versions. If you're new to git, I recommend http://gitready.com/ and http://progit.org/ as resources for learning the git workflow. – bta Feb 23 '12 at 18:55
  • bta - this was my workflow in svn. I just make a copy of the old trunk just for easy reference. I know its not necessary to keep it. – fregas Feb 23 '12 at 22:44
  • waffl - okay, if we are talking subversion, its implemented differently than Git, although the concepts are the same. I don't necessarily put the webroot as trunk. Trunk is the root to ALL the source code and dependencies of the project. Trunk needs to have everything to build and run the project. I do work on small things in the trunk and big ones in the branch. I do deploy the branch. Archiving the old trunk is a matter of just copying it into tags and renaming it. Then i copy my branch (e.g. MyApp 2.0 ) to the root of the svn repo and rename it to trunk. – fregas Feb 23 '12 at 22:45
1

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

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110