Git for Administrators

Revision as of 22:13, 29 March 2011 by David Mudrak (talk | contribs) (Installing a contributed extension from its Git repository: Trivial typo fix)

Jump to: navigation, search

Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: Git for Administrators.

An alternative way to maintaining your Moodle server via CVS is using Git. This page describes how to maintain a copy of Moodle on your production server which can easily be upgraded using Git. If you have customisations of Moodle core code, you are advised to follow the instructions in the Quick Git start guide for Moodle development.

Obtaining the code from Git

You can find the official Moodle git repository at git:// and git:// To initialize your local checkout, use

   git clone git://                    (1)
   cd moodle
   git branch -a                                                   (2)
   git checkout -b MOODLE_19_STABLE origin/MOODLE_19_STABLE        (3)

The command (1) initializes the new local repository as a clone of the upstream moodle.git repository. The command (2) lists all available branches. Use the command (3) to switch to a different branch than the default 'master'.

Updating your installation

The Moodle development team performs integration and testing of fixed bugs every Monday and Tuesday. On Wednesday you can install all patches by updating your code. Check the shortlog to see if the official repository has been already updated or not.

   cd /path/to/your/moodle/checkout
   git pull

Installing a contributed extension from its Git repository

For example, let us say we want to install the Book module form its Git repository into our Moodle 2.0.

   cd /path/to/your/moodle/checkout
   cd mod                                                          (1)
   git clone git:// book      (2)
   cd book
   git checkout -b MOODLE_20_STABLE origin/MOODLE_20_STABLE        (3)
   git branch -d master                                            (4)

The command (1) changes the current directory into the mod folder of your local Moodle clone. The command (2) creates a new subdirectory book and makes a local clone of Petr Škoda's vanilla Book repository. The command (3) creates a new local branch that will track the remote branch with a Book version for Moodle 2.0. The command (4) deletes the master that was created automatically by git-clone in (2) as we do not want it in this production checkout.

Now it is wise to put the new directory mod/book/ to the list of ignored files of the main Moodle clone.

   cd /path/to/your/moodle/checkout
   cat /mod/book >> .git/info/exclude

To update your Moodle installation now, you must visit both Git repositories and pull changes from upstream.

   cd /path/to/your/moodle/checkout
   git pull
   cd /path/to/your/moodle/checkout/mod/book
   git pull

Writing a shell script with these lines in the root of Moodle installation is a very good idea. Otherwise it is easy to forget what Git repositories are there within the main Moodle repository.

Important note

For pretty long time, the Moodle 2.0.x stable code lived on master branch instead of MOODLE_20_STABLE. Moodle 2.0 was then branched but if you stayed on master, you would update to the latest development version, which is not desirable on a production server. This was an exception caused by the transition from CVS to Git and should never happen again.

Using a GUI


See also