If you want to see what is done inside the script UpdateMoodle.sh please feel free to open it with a text editor. It is only a text file but it uses the macOS feature to open a file with a chosen program via doubleclick.

We setup the system utility Terminal to open the file UpdateMoodle.sh and to run the contained script automatically. So everything can be done with a doubleclick. It's easy and everybody can do it!!
#! /bin/sh
#! /bin/sh
#
# This GIT installer for macOS is part
# of the installation package Moodle4Mac
#
# 20241007 - Ralf Krause
#
echo
echo "+--------------------------------------------+"
echo "| GIT updater for your local Moodle server"
echo "+--------------------------------------------+"
echo
cd /Applications/MAMP/htdocs
if ! test -e moodle405/.git ; then
## the first git update must get everything including .git
git clone --depth 1 -b MOODLE_405_STABLE https://github.com/moodle/moodle.git moodle405-git
if test -e moodle405-git ; then
if test -e moodle405 ; then
if test -e moodle405/config.php ; then
cp moodle405/config.php moodle405-git/.
fi
DATE=`date +%Y%m%d-%H%M`
mv moodle405 moodle405-$DATE
fi
mv moodle405-git moodle405
fi
## the old folder can be deleted now
## if you want to do this please remove '##' from the following line
## rm -R moodle405-*
else
## the next git update only gets the new files
cd moodle405
git pull
cd ..
fi