Posts from "April 2011"

Tips: How to set-up, maintain, and update a web site using git and github

Here are some basics of using git and github to initially get or update the code to your site.  I've found this is an easy way to initial install, and the perform updates on my web sites.  There is a little bit of overhead (~105 MBytes), however the reduction in effort is worth it in most cases.

We’ll assume you have shell access to the server, and git is installed (‘git –v’ should work).

To (initially) Install ExponentCMS as your website:

  • ‘cd’ to the root folder of your web (this folder should be empty since you are building a site from scratch.)
  • To get the latest released code contained in the “master” or default code branch:
git clone git://github.com/exponentcms/exponent-cms.git .
  • HOWEVER, the folder MUST be empty for the clone to work.  The work-around is to leave the "." off the end of that last command and then mv it to the root folder
    • git clone git://github.com/exponentcms/exponent-cms.git
    • mv exponent-cms/* .
  • Launch the web site installer and complete the installation. (www.mysite.org/install/index.php)
  • Install any custom themes or other local mods.

To update the code on your site to the most recent released version:

  • ‘cd’ to the root folder of your web (this folder should be empty since you are building a site from scratch.)
  • First save any local modifications to prevent any (merge) conflicts:
git stash save
  • Next, download and merge the updated code:
git pull
  • Next, restore any local modifications, if you choose (optional).  If you are (still) using a standard/shipped theme your theme configuration settings were reset to default unless you restore them):
git stash pop
  • Then, log into your site as an admin user.  It's always a good idea to run an 'upgrade' so the database and any other changes are incorporated. (www.mysite.org/install/index.php)  In many cases, you'll see a message recommending the upgrade with a link to start the upgrade process.

To switch the code on your site to a development or pre-release testing version:

  • ‘cd’ to the root folder of your web (this folder should be empty since you are building a site from scratch.)
  • First save any local modifications in the current (master) branch:
git stash save
  • Next, switch to and download the development/testing code:
  • To get the bleeding edge code contained in the “develop” branch:
git checkout develop
  • (or) To get and help test a version prior to its release contained in the “release/xxx” branch:
git checkout release/xxx
  • (of course you’ll need to know the release tag or do a ‘git branch –a’ to list the branches)
  • Please bear in mind the release/xxx branch is temporary and will only exist between code freeze and code release.  The “xxx” will be the actual release tag like “v2.0.8”
  • If you’re having problems establishing the develop branch when working from an earlier clone:
git fetch
git checkout –-track –b develop origin/develop
git pull
  • If you’re having problems establishing the release/xxx branch when working from an earlier clone:
git fetch
git checkout –-track –b release/xxx origin/release/xxx
git pull
  • If you are using a custom theme or modifications (in the custom theme folder), your customizations remain intact.  However, if you were modifying system code, it'll have been replaced by the code from the git repo.
  • Log into your site as an admin user and run the upgrade process (www.mysite.org/install/index.php)

To switch the code on your site BACK to the release version:

  • ‘cd’ to the root folder of your web (this folder should be empty since you are building a site from scratch.)
  • First save any local modifications to your development/testing branch:
git stash save
  • Next, switch to the release code branch:
git checkout master
  • Next, download any updated code:
git pull
git stash pop