Updating Moodle
Updating moodle the git way is less error prone, more fun and keeps your plugins intact!

My son sometimes wakes up in the early morning hours to let out a wheep and fall asleep again seconds later. Which I cannot as easily.
With a baby snuggled up to me, I dare not move much. Except for fingers over my phone's keyboard. Terminus connects me to a world of servers.
Why did git pull not update my fresh moodle installation as it should? A little bit of research tells me that git is tracking changes in chmod. And I did chown and chmod the moodle plugin folders to allow plugin installations through the ui.
To remedy this, I run:
git config core.filemode false
Why I think this is ok
Git is a version control system, a marvelous one at that. Using it as an update manager is smart, just not quite what it was made for. So we nudge it a bit to make it work for our purpose.
Et voilà. I can update moodle to the next minor release without problems. Before I do, I quickly snapshot my container to have a backup.
sudo lxc snapshot moodle before-update
Then the update goes:
sudo -u www-data php admin/cli/maintenance.php --enable
git pull
sudo -u www-data php admin/cli/upgrade.php
sudo -u www-data php admin/cli/maintenance.php --disable
Minutes later, my site is back up and running. Great! Confident with my success, I move on to the major release that just came out, Moodle 4.2:
sudo -u www-data php admin/cli/maintenance.php --enable
git branch --track MOODLE_402_STABLE origin/MOODLE_402_STABLE
git checkout MOODLE_402_STABLE
git status
sudo -u www-data php admin/cli/upgrade.php
sudo -u www-data php admin/cli/maintenance.php --disable
If all goes well, your output from executing admin/cli/upgrade.php should report success:
Command line upgrade from 4.1.3+ (Build: 20230427) (2022112803.01) to 4.2+ (Build: 20230427) (2023042400.01) completed successfully.
And best of all, because I never staged anything, all my installed plugins remain untouched by git and working in moodle.