Note: You are currently viewing documentation for Moodle 2.4. Up-to-date documentation for the latest stable version of Moodle may be 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}}")
 
(2 intermediate revisions by 2 users not shown)
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.
 
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!!!--[[User:Tim Hunt|Tim Hunt]] 09:09, 15 March 2011 (UTC)''
 
''Please edit it to the right way to do it then, it hasn't caused me any problems (yet) :-)[[User:Mark Johnson|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 <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

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.