I've written before about using subversion and Piston for hosting this particular site.
The problem with using subversion for websites is that it is not available when working offline. (Assuming that your repository does not reside on your laptop.) While this is not normally an issue for sites based around a CMS, e.g WordPress or Drupal, there are times that having access to version control would be useful. Examples include working on a new Drupal theme or doing old-fashioned HTML web development.
The solution to this problem is to use a distributed version control system. In a distributed control system, a local repository is maintained on the development machine which is then periodically synchronized with the master repository. One such system is git. Git is used by the Linux kernel developers and many other projects besides. It also has the feature of being able to interact with subversion which is useful for me since I'm not ready to phase out my subversion repository.
At a glance, git appears to be superior for websites. Aside from the advantage of being distributed, it also stores its metadata in a subdirectory of the top-level directory called .git
. Compare this against subversion which stores its metadata in a subdirectory called .svn
within each directory and subdirectory of the repository. This means that if you have directories that are owned by the webserver (this happens on websites sometimes), you have to get them chown
'd before you can add them to a subversion repository. With git, this isn't an issue. (Git will not preserve the file ownership but this isn't usually a significant issue.)
There are a few differences between subversion and git. First, git does not use a central repository like subversion. A common structure in subversion would be to have a central repository and then each project would be a subdirectory. In git, each project has its own repository. While you can check out specific directories from subversion, you can only check out the entire repository for git.
While subversion allows checking in empty directories, git does not. This can be an issue for some applications. The Git FAQ suggests, as a workaround, adding a fiele called .gitignore
to each otherwise empty directory. Git will then check in the .gitignore
file.
Git does not appear to support anything like svn:externals
. However, this does not appear to be a significant issue. Version 2 of Piston supports git (as well as subversion) so it can be used to fulfill the same purpose. (Correction: As Jakub Narębski points out in the comments, git's submodule mechanism is a lot like svn:externals
.)
Using git is mostly the same as with subversion. If you are familiar with subversion, you should pick up on the commands relatively quickly. (And if you're completely new to version control, I suggest getting Pragmatic Version Control Usng Git.) The one major catch is: Always remember to push commits to the central repository with svn push origin master
. If you do not do this, the local commits will never reach the repository. This is an issue if you expect to redeploy the site from that repository in the future.
Finally, when using Git and Piston, you will need to add these directives to block access to the metadata:
RedirectMatch 404 /\\.git(/|$) RedirectMatch 404 /\\.piston.yml
If still checking out from a CVS repository, e.g. from Drupal, you will still need to include this as well:
RedirectMatch 404 /CVS(/|$)
Comments
git submodules are (pegged) svn:externals done right
Git does not appear to support anything like svn:externals
What about git-submodule?
I missed that...
I missed that in the documentation. Yes, git-submodule does appear to function almost exactly like svn:externals.
However, Piston seems to be a better solution to the problem.
Add new comment