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

Maintaining Moodle customisations with Git: Difference between revisions

From MoodleDocs
No edit summary
(Replaced content with "{{Moved_to_dev_docs}}")
 
Line 1: Line 1:
'''This page is a work in progress'''
{{Moved_to_dev_docs}}
 
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.
 
First, from your moodle directory, create a branch of <tt>master</tt> which will contain your customised Moodle. This is the branch you'll publish to other servers.
git checkout master
git checkout -b mycustommoodle
 
Switched to a new branch 'mycustommoodle'
Next, 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"
 
Switch back to the <tt>mycustommoodle</tt> branch and merge the changes
git checkout mycustommoodle
git merge myfeature
Any future development can take place on the myfeature branch, and be merged into mycustommoodle 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
git checkout mycustommoodle
git merge 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 <tt>git merge origin/master</tt>.
 
To resolve this, you will need to find the conflicts (the attempt to merge will tell you where they are) and resolve them.  The [http://www.kernel.org/pub/software/scm/git/docs/git-merge.html|<tt>git merge</tt> 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
Once a conflict has been resolved, even if you keep your local modification over the upstream modification, there wont be a conflict next time you merge.

Latest revision as of 08:48, 16 June 2011

This development related page is now located in the Dev docs.

See the Maintaining Moodle customisations with Git page in the Dev docs.