Installing and upgrading help

Best GIT upgrade Workflow

Picture of Andrew Chlup
Best GIT upgrade Workflow

So, I switched to Git when we moved our Moodle server to 2.2 and now I'm stumped on how to upgrade to 2.3

I've tried switching the branch I'm using and then doing a "git pull". This gives me errors on the update screen. The errors says that I have old files that won't work with upgrade.

How do I get git to pull 2.3 and replace 2.2? It looks like rebase or merge but I'm stumped.

Any thoughts for a Git noob would be greatly appreciated.



Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Best GIT upgrade Workflow
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

Have you made any customisations to the Moodle code?

If you have not, you should be able to do

git checkout -b MOODLE_23_STABLE origin/MOODLE_23_STABLE

or something like that. If you have made customisations, then you need to work a bit harder, and there are various options.

Average of ratings: -
Picture of JF Bill
Re: Best GIT upgrade Workflow

I do ahve the same need to upgrade Moodle now that we want to move to GIT and we maintain local modifications. There are tons of workflow on the web but I'm really confuse as to which fits the best Moodle with customization. Should we use a fork from github or simply use GIT.

What do you suggest as the best worflow for my situation ?

Thank you 

Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Best GIT upgrade Workflow
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

The thing that makes git confusing is that there are lots of different possible work-flows. This is not a bad thing, but it does make it harder to learn.

As an example, think about writing a forum post - and here I am talking about the very low level, the actual process of typing a sequence of characters in the right order. Just think about all the different ways you can do that. Do you just type perfectly, and never have to correct that? Or do you often make mistakes, and have to go back and edit? When you have to edit, how do you do it? Do you just delete backwards until you have got back to the last character and retype, or do you move the insertion point back there to edit? When you move the insertion point, do you click with the mouse or do you use the arrow keys, or do you choose depending on where you have to move to? and so on. Imagine having to write detailed instructions for editing text wink

Anyway, the reason that is not a problem for editing text is that you can clearly see the current sequence of characters on screen, and you know what sequence of characters you would like, so you can use you favourite methods for editing text to get to where you want to be.

Anyway, git is flexible in a similar way. It is a tool for managing sequences of versions of software, rather than characters, and there are various ways you can edit things one step at a time. Perhaps, rather than thinking about particular workflows (how you edit), it is better to focus on "how do you see the current situation?" and "what situation do you want to be in?".

To see the current situation, I find the tool gitk to be the best. It gives you a graphical view of all the versions you have got. It can take a while to get the hang of what it is showing you, particularly since Moodle is being actively developed, and so you have about 100 new versions every week. (Typically with very small changes between each.) Other ways to see what is going on are the commands 'git status', 'git branch' and 'git log'.

The situation you want, when you have customisations, probably looks like this: You have a given, the MOODLE_24_STABLE branch (or whichever branch you are following). Then you have your version of the code, which is that version, plus a few changes. The best thing is to commit your changes to git on another branch, for example called MYMOODLE.

So, to start off, you create your branch starting from the standard branch:

git checkout --track MYMOODLE MOODLE_24_STABLE

then you make some change, and then you commit them to your branch, which you coudl do with

git commit -a -m "Hack around with feature X."

You may repeat this several times, as you make different customisations.

Then, at some point you will want to update to the the latest versoin on the Moodle 2.4 stable branch. You do that with the command

git pull

As with a CVS update, you may get merge conflicts at that point, in which case you will have to solve them manually.

From time to time it is worth reading the documentation about the commands you use frequenty, to try to understand what they are rearlly doing. Also, it is a good idea to keep the gitk window open while you do things, and refresh it frequently, so you can see what effect your commands are having. Sugested documentation:

Average of ratings: -
Picture of Visvanath Ratnaweera
Re: Best GIT upgrade Workflow
Particularly helpful Moodlers

This discussion could be a good start: "GIT for dummies" (caution: there is no double meaning behind the title).

The official documentation is
Average of ratings: -