Note: You are currently viewing documentation for Moodle 2.3. Up-to-date documentation for the latest stable version is available here: Maintaining Moodle customisations with Git.

Maintaining Moodle customisations with Git

From MoodleDocs
Revision as of 09:32, 15 March 2011 by Mark Johnson (talk | contribs)

This page is a work in progress

Git makes it very easy to maintain local customisations to Moodle alongside updates from the official Moodle repository. This page assumes you installed Moodle following Installing Moodle from Git repository. It also assumes you understand basic version control principles (repositories, branches, conflicts) and have a basic working knowledge of Git.

From your moodle directory, create a new branch for developing your customisation, and move to that branch:

git checkout -b myfeature
Switched to a new branch 'myfeature'

This will give you a seperate copy of the Moodle code to work on without affecting the master branch. It's not recommended that you do this on your production server, as it will cause the code to be available immediately as it's saved.

Do your customisations, add any new files to git, and commit the changes

git add .
git status
git commit -m "Description of the change"

Ouch! this next bit is a really bad idea. I don't know what you are trying to achieve, but this is not the right way to do it!!!--Tim Hunt 09:09, 15 March 2011 (UTC)

Please edit it to the right way to do it then :-)Mark Johnson

Switch back to the master branch and merge the changes

git checkout master
git merge myfeature

Any future development can take place on the myfeature branch, and be merged into master in this way

Even after local modifications have been made, you can pull in updates from the official git repository

git checkout master
git fetch
git merge origin/master

Conflicts

If you create a local modification to a file, and that same file is modified in the official repository, you may find that a conflict is created when you do git merge origin/master.

To resolve this, you will need to find the conflicts (the attempt to merge will tell you where they are) and resolve them. The git merge man page has more information on the presentation and resolution of conflicts.

After the conflict is resolved, you'll need to commit the resolved files.

git commit -a