ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Using git to Manage an ExpressionEngine website : Starting the conversation

June 02, 2009 2:08pm

Subscribe [29]
  • #16 / Jun 12, 2009 9:07am

    Stephen Lewis

    466 posts

    Another question. Why git instead of SVN?

    I much prefer it for the following reasons:
    1. Branching and merging is so much easier.
    2. No .svn folders littering the project. Git keeps everything in one folder, in the root of the project.
    3. Git has become something approaching a de-facto standard for managing EE addons.
    4. For reasons I can’t explain, I just find git nicer to work with, even though I had a nice GUI client for SVN, and do all the git stuff via the Terminal.

    Cheers,
    Stephen

  • #17 / Jun 12, 2009 1:39pm

    Ryan M.

    1511 posts

    @Richard: 9 times out of 10 I’m just working on the files locally, but still tied to the remote “live” DB, so there is no database duplication at all. You can certainly dupe the DB and work locally, and Capistrano can help with automating that whole process. But most of the time I’m working on the template files locally, but getting the data from the “real” DB.

  • #18 / Jun 13, 2009 2:21am

    Richard Frank

    200 posts

    @Stephen

    Thanks, will give it a go.

    @Masuga

    Not a bad idea at all!

    Do you not have latency issues when dealing with a remote server. My server is between 20ms and 50ms away from me, depending on how the internet is feeling (in South Africa, our internet is a bit patchy).

    Haven’t tried it, but I assume on a page with many queries, this could be a problem. Otherwise, I think you’ve touched on a very good solution.

  • #19 / Jun 13, 2009 9:57am

    Ryan M.

    1511 posts

    @Richard: There can be some latency, but it’s usually not too bad. If I know I’m only going to be working on template changes, I may make the effort to do a SQL dump and alter my config.php file to work locally, but I’ve found that most of the time, I can just point to the main DB, usually via IP address. The issue there is: your host better allow remote mySQL connections for that to work, and if they don’t, then you’re going to have to dupe the DB all the time.

  • #20 / Jun 15, 2009 3:36am

    Richard Frank

    200 posts

    Well, I had a look at git and watched the very entertaining Linus Torvalds video, and decided to give it a bash.

    I agree with everything you said Stephen, I think it is highly intuitive and fits into my work process well. SVN always left me a little wary and confused. I like the idea of my own offline repository - I think the distributed nature is great. If anyone wants to try out git, I recommend dropping $9 on the peepcode screencast.

    http://peepcode.com/products/git

    Ok Stephen, bring on the third installment!

    So the way I see it, I have my own dev setup, I have a staging server hosted somewhere, and I have the live production site, all of which have these invisible .git directories storing a full history of development. The repository isn’t just a repository, but actually a “live site” I can play with or even show to the world.

    In that case, I would store everything (except caches), including binaries, just because it’s easier, and sync the whole lot between the three servers. I hope git doesn’t try to version a JPG though, if I resize it but use the same name - will it try to do a diff on it for instance, lol.

  • #21 / Jun 17, 2009 3:35pm

    Stephen Lewis

    466 posts

    Hi Richard,

    Glad you’re finding the blog posts helpful, the third installment should be out by the end of the week, once I get this pesky client work out the way.

    I second your recommendation of the PeepCode screencast; well worth the 9 bucks.

    So the way I see it, I have my own dev setup, I have a staging server hosted somewhere, and I have the live production site, all of which have these invisible .git directories storing a full history of development. The repository isn’t just a repository, but actually a “live site” I can play with or even show to the world.

    Exactly right.

    In that case, I would store everything (except caches), including binaries, just because it’s easier, and sync the whole lot between the three servers. I hope git doesn’t try to version a JPG though, if I resize it but use the same name - will it try to do a diff on it for instance, lol.

    You can include rules specifying which files git should ignore (for example, all cache directories); I’ll be touching on that in the 3rd installment. Regarding image files, it depends on the site, but I quite frequently include images in the repo; git (and SVN, from what I recall) can handle them just fine.

    If you’d prefer to keep images out the repo, it’s easy to set up a rule to ignore them.

    Cheers,
    Stephen

  • #22 / Jul 10, 2009 11:38am

    radar77

    28 posts

    Hi Guys,

    Hope you don’t mind if I jump on this thread, I find it really interesting.

    I just got started myself with managing an EE installation with Git and also have been testing out deploying with Capistrano. I got started with Dan Benjamin’s (Hivelogic) excellent article. Stephen, I’ll definitely be checking out your articles as well. And Ryan, would love to see your notes on the subject as well! Devot:ee is an amazing resource, thanks for it.

    —-

    I’ve done pretty well managing with Git and deploying with Capistrano up to this point. However, the biggest problem I’ve had is figuring out how to best juggle the database from a local development and live production standpoint.

    I’ve just setup a new EE installation on a Slicehost server with the Git/Capistrano setup. In the past, I’ve developed locally on my Mac using MAMP, which works great for development and then pushing up to a production server. But, I’d really like to find a better way to manage a site during its life cycle — developing new features, etc. locally and then deploying to the live production site.

    I’ve been experimenting with connecting to the live database on my local setup, but the themes path, template path and such are different on my local machine then they are on the production server and these appear to be locked into the database, rather than in the config.php file.

    Do you guys have any advice on how to manage this? I would really appreciate your feedback.

    Cheers,
    Michael Reienr

  • #23 / Jul 10, 2009 12:04pm

    Richard Frank

    200 posts

    Michael, have a look at this: http://www.inmostlight.org/2007/11/configuring-expression-engine-for-multiple-servers

    Keep going and report back on your progress.

  • #24 / Jul 11, 2009 11:09pm

    minimal design

    356 posts

    Very interesting thread… @Stephen, is it me or the link to your first installment is broken on your site? Thanks!

  • #25 / Jul 13, 2009 4:37am

    Stephen Lewis

    466 posts

    Hello all,

    Apologies for abandoning this thread (and the blog series) for the last couple of weeks, I’ve been away on holiday. Back in the swing of things now, and hoping to get the third installment out the door this week.

    @radar77: what @Richard Frank said.

    @minimal design: links are working fine for me.

    Cheers,
    Stephen

  • #26 / Jul 13, 2009 11:15am

    radar77

    28 posts

    Michael, have a look at this: http://www.inmostlight.org/2007/11/configuring-expression-engine-for-multiple-servers.

    Thanks @Richard.

    I had forgotten about ‘path.php’ and didn’t realize I could set global variables straight away in ‘config.php.’
    So, setting global variables in ‘config.php’ overrides what is set in the Control Panel?

    This works great now.
    I’ve now added ‘config.php’ to my .gitignore file so I can configure my local machines a little differently.
    I set up a a link to my remote MySQL database from my local IP only, but the production server connects to the same database on localhost.

    I’ll report back as I continue down this path.
    I hope this thread can thrive because this method is very promising.

  • #27 / Jul 13, 2009 12:47pm

    Ryan M.

    1511 posts

    Overriding the config variables in config.php is key to getting this to work. I do have an article forthcoming on devot:ee, but I’ll share the most important block of the config.php right now. I put this at the bottom of every config.php file:

    // Config Overrides
    // See: <a href="http://expressionengine.com/wiki/Config_Overrides/">http://expressionengine.com/wiki/Config_Overrides/</a>
    // See: <a href="http://expressionengine.com/wiki/Hidden_Configuration_Variables/">http://expressionengine.com/wiki/Hidden_Configuration_Variables/</a>
    $conf['system_folder']      = "SYSTEMFOLDERNAME";
    $conf['site_url']           = "http://${_SERVER['HTTP_HOST']}/";
    $conf['cp_url']             = "http://${_SERVER['HTTP_HOST']}/${conf['system_folder']}/index.php";
    $conf['tmpl_file_basepath'] = "${_SERVER['DOCUMENT_ROOT']}/site_templates";
    $conf['theme_folder_path']  = "${_SERVER['DOCUMENT_ROOT']}/themes";
    $conf['theme_folder_url']   = "http://${_SERVER['HTTP_HOST']}/themes/";
    $conf['captcha_path']       = "${_SERVER['DOCUMENT_ROOT']}/images/captchas";
    $conf['captcha_url']        = "http://${_SERVER['HTTP_HOST']}/images/captchas";
    $conf['avatar_path']        = "${_SERVER['DOCUMENT_ROOT']}/images/avatars/";
    $conf['avatar_url']         = "http://${_SERVER['HTTP_HOST']}/images/avatars";
    $conf['photo_path']         = "${_SERVER['DOCUMENT_ROOT']}/images/member_photos/";
    $conf['photo_url']          = "http://${_SERVER['HTTP_HOST']}/images/member_photos";
    $conf['sig_img_path']        = "${_SERVER['DOCUMENT_ROOT']}/images/signature_attachments/";
    $conf['sig_img_url']         = "http://${_SERVER['HTTP_HOST']}/images/signature_attachments";
    $conf['prv_msg_upload_path'] = "${_SERVER['DOCUMENT_ROOT']}/images/pm_attachments/";

    All you have to change is the system folder name. You may also with to change “tmpl_file_basepath”, depending on where you like to keep your templates folder. For those things that aren’t allowed to be overridden with the config file - you’ll want to use relative paths in the CP, for example, with the file upload paths.

  • #28 / Jul 13, 2009 2:00pm

    Ryan M.

    1511 posts

    Also, if you’re using Brandon Kelly’s FieldFrame, you need to apply a hack if you’re using a version earlier than 1.2.0. If you’re using the most up-to-date version, you also should add the following two two variables, below the block in my previous post.

    // FieldFrame 1.2.0+
    $conf['ft_path'] = "${_SERVER['DOCUMENT_ROOT']}/${conf['system_folder']}/extensions/fieldtypes/";
    $conf['ft_url'] = "http://${_SERVER['HTTP_HOST']}/${conf['system_folder']}/extensions/fieldtypes/";
  • #29 / Jul 13, 2009 2:23pm

    minimal design

    356 posts

    Going slightly on a tangent here, but could there be any security issues related to having a .git/ directory in the web root (ie. public_html, or whatever it’s called on your particular server)? For instance, is there anyway for someone (smarter than me) to access the content of the .git/ directory and somehow reverse engineer the objects files to figure out your database password from config/database.php

    Is that impossible? Do you need to protect the .git/ directory in any way?

    I’m just thinking out loud here, forgive me if this is a silly question… Just started using Git 2 days ago 😊

  • #30 / Jul 13, 2009 2:33pm

    Richard Frank

    200 posts

    I think anything with a . in front of it is not publicly accessible on a unix server, hence we can’t do something like this:

    http://expressionengine.com/.htaccess

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases