Finding specific Moodle versions in the Moodle Git Repository

The key to working with the Moodle git repository (https://docs.moodle.org/31/en/Git_for_Administrators) is to look at changes to the version.php file in the main moodle directory which tells you the moodle version.

You can use the whatchanged git command to get a summary of all changes and tags.

git whatchanged -p version.php

But more than likely if you are upgrading or patching you want to find a specific Moodle version. For example, I want to find the commit that relates to “Moodle release 3.1.2” which has the following in the version variable:

2016052302.00

To find that use whatchanged to search for that value like so:

git whatchanged -p -S2016052302.00 version.php

This gets you the results that revolve around that version change, e.g. perhaps you want the change from version v3.1.1 to v3.1.2.
Once you have the commit hash e.g. f851201 you can then checkout that hash for example to see that specific version. Make sure you confirm you have what you need by looking at version.php first.

git checkout f851201-B moodle

How to get a list of the Moodle Core Git Branches

Use the following git command to get a list of all the Moodle core git branches.

git ls-remote git://git.moodle.org/moodle.git | grep head

This returns a bunch of hashes and the refs/heads/[MOODLE_XX_STABLE] branches. You can guess these, so this is just to check what they are without having to clone the entire repository. Plus you’ll know when a new stable branch is available in the repository.

To clone a specific branch (e.g. say I only want Moodle 2.2), use this command in the relevant target directory (note the -t to include tags so you can go to specific tags like v2.2.2):

git clone -b MOODLE_22_STABLE git://git.moodle.org/moodle.git