How to change Moodle version using GitHub branch

To change your Moodle version using Git, you primarily use the git checkout command to switch between version-specific branches. This process is the standard way to "upgrade" your site’s codebase. [1, 2, 3, 4]
1. Preparation and Backup
Before making any changes to your production environment, you should always back up your site, including the database and the moodledata directory. Moodle upgrades are generally one-way; once the database is updated, you cannot easily revert without a full restoration. [1, 2, 3, 4]
2. Fetch the Latest Code [1]
Navigate to your Moodle root directory in the terminal and ensure your local Git repository knows about all available branches from the official source.
bash
git fetch --all
Use code with caution.
3. Identify the Target Branch
Moodle uses a specific naming convention for its stable branches: MOODLE_XX_STABLE (e.g., MOODLE_405_STABLE for version 4.5). You can list all available remote branches to find your target: [1, 2, 3, 4]
bash
git branch -a
Use code with caution.
4. Switch to the New Version [1]
Use the checkout command to switch your local files to the desired version. It is best practice to create a local tracking branch that follows the remote version. [1, 2, 3, 4]
Example: Switching to Moodle 4.5
bash
git checkout -b MOODLE_45_STABLE origin/MOODLE_45_STABLE
Use code with caution.
If the branch already exists locally, simply use: git checkout MOODLE_45_STABLE.
5. Finalize the Upgrade
Changing the code via Git only updates the files. You must now trigger the database upgrade to match the new code. [1, 2, 3]
  • Via Web Interface: Log in to your site as an administrator and go to Site administration > Notifications. Moodle will detect the version change and guide you through the database update.
  • Via CLI (Recommended): Run the upgrade script directly from your terminal to avoid web server timeouts.
    bash
    php admin/cli/upgrade.php
    
    Use code with caution.
    [1, 2, 3, 4, 5]
Important Tips
  • Maintenance Mode: It is highly recommended to put your site into Maintenance Mode before starting.
  • Check Plugins: Ensure any third-party plugins you use are compatible with the new Moodle version.
  • Permissions: After running Git commands, verify that your web server still has the correct ownership and permissions for the Moodle directory.
  • Reference: For more detailed instructions, see the official Git for Administrators documentation on MoodleDocs. [1, 2, 3]

Post a Comment

0 Comments