Live data from Hacker News

Using git to manage a website

toroid.org

21–30 of 52 posts

Re: Using git to manage a website

#21

Earlier quoted context omitted.

Managing the codebase is straightforward -- that's what git's designed for. My question was more about the actual site contents, which will reside in the database. Can you use git for tracking changes to the contents?

Probably not. You're better off logging your MySQL queries and filtering out the UPDATE, INSERT, and DELETE queries for the tables you're interested in.

Interesting suggestion. Do you know if anyone is doing it this way?

Re: Using git to manage a website

#22

I use Fabric with mercurial to achieve a similar effect typing "fab prod deploy" - see Steve Losh's blog posts or bitbucket.org/kevinburke/goodmorningcmc

You can do the same with Capistrano. However for a very basic static site it does sound simpler to just use a post-receive hook rather than having a script ssh in and do a pull.

Re: Using git to manage a website

#23
post #12

I've played with this - in the end I ended up using custom scripts and/or Capistrano scripts (along with git of course) to handle actual deployments. It provided more control and more features, while still letting me leverage git.

Yeah, sounds familiar. I've been cooking up a way to manage a locally mastered static html website hosted in Amazon CloudFront. I may well use it as an opportunity to learn git (over SNV)...

Re: Using git to manage a website

#24

Earlier quoted context omitted.

Managing the codebase is straightforward -- that's what git's designed for. My question was more about the actual site contents, which will reside in the database. Can you use git for tracking changes to the contents?

Probably not. You're better off logging your MySQL queries and filtering out the UPDATE, INSERT, and DELETE queries for the tables you're interested in.

I would advise against that. There are too many places in he mess of tables of data configuration that might refer to specific auto-increment id columns were things will get out of sync. Basically you are trying to do MySQL replication on specific tables only, but there are too many relationships among all the tables.

If it is a small amount of content, such as a handful of pages for a brochure site, putting them in a feature might be best.

If it is a site where customers or visitors generate content on the site, then periodically re-initialize your dev and staging environments with copies of the live DB, running it through a script to anonymize all the user info and change passwords and etc.

If you want to create content on your dev and move it live, then doing a full database copy and moving it live, with settings that are particular to live overridden in settings.php, is probably the best way. I advise against this, basically you are re-launching the site for every change.

If you are truely desiring to be able to create content in multiple different places and move it to live, then probably the best thing to do explicitly program and configure for that, by specifying feeds of the content and setting up the different sites to ingest each other's feeds.

Re: Using git to manage a website

#26
post #9

Earlier quoted context omitted.

To elaborate on dolinsky and the article, if your web server is doing a "git pull", it means it has ssh access into your workstation. If someone breaks into your web server, this means that they have ssh access into your workstation as well by simply using the keys on your web server. This is bad, very bad. If you push to your web server, only your public key is exposed if your web server is compromised.

Not necessarily. If you run an ssh-agent locally and configure ForwardAgent to 'yes' for connections to your web server you can ssh to your server and use ssh from it without actually putting your private key on it. I'd still recommend pushing to a server though.

An excellent discussion about this exact topic came through HN yesterday. See http://news.ycombinator.com/item?id=2183415, and in particular the comments.

Re: Using git to manage a website

#27

What about using git to backup an entire hard drive? Maybe using bitbucket (or github if you don't mind sharing your data with the world). Living on the cloud has never been so easy :-D

Performance would be nightmarish. Git is super elegant and great, but not very performant. Imagine having to deltify a terabyte of data? Good luck with that!

Re: Using git to manage a website

#28
post #24

Earlier quoted context omitted.

Probably not. You're better off logging your MySQL queries and filtering out the UPDATE, INSERT, and DELETE queries for the tables you're interested in.

I would advise against that. There are too many places in he mess of tables of data configuration that might refer to specific auto-increment id columns were things will get out of sync. Basically you are trying to do MySQL replication on specific tables only, but there are too many relationships among all the tables. If it is a small amount of content, such as a handful of pages for a brochure site, putting them in…

FWIW, I found two takes on database versioning: http://www.gsdesign.ro/blog/mysql-database-versioning-strate... https://launchpad.net/dbvcs

Re: Using git to manage a website

#29
post #8

Earlier quoted context omitted.

that's what we do in conjunction with http://drupal.org/project/features , bugs aside it works well but what you want in code and what you want in the DB will vary from page to page and feature to feature so often just manually redo stuff (in dev env and then again in production) because deploying changes by code is more effort then its worth.

Managing the codebase is straightforward -- that's what git's designed for. My question was more about the actual site contents, which will reside in the database. Can you use git for tracking changes to the contents?

No, git will not track database changes. Features however can handle much of the configuration (that is typically contained in the database) in code, which can then be managed with git.

If you want to create content on your dev or staging site and push it to production, check out the deploy module: http://drupal.org/project/deploy

Tracking changes to nodes in production is probably best left to Drupal's built in node versioning system. Diff (http://drupal.org/project/diff) is a handy module to track changes between revisions and if you want a little more advanced workflow check out revisioning (http://drupal.org/project/revisioning) and workflow (http://drupal.org/project/workflow). Good luck!

Re: Using git to manage a website

#30
post #18

I do something similar, but I keep the "central" repository in another location on the server and pull from that.

That's what I do, except I use svn rather than git.

Nice to hear I am not alone on this. The advantage I find is that it makes my deployments more explicit, and my pushes too and from the repository are as often as I feel.

With GIT thats a moot point in the linked article so long as you are using branches for everything and remembering to push them as well, but sometimes I just want to fix something quickly and do so without a branch. I dont care what people say when you start storing a lot of stuff in GIT a branch can take some time to process.

Post reply on HN