Using Git with Moodle – Side Load

Posting assumes you can install git via your package manager (yum/apt-get/whatever).  Many distros now included it when distro installed.

Dunno if you have it?   which git [ENTER]

IF the above doesn’t respond with the path to git (normally /usr/bin/git) then your server doesn’t have it installed.

Situation:  have an existing moodle but installed via ftp/wget or some other method of acquiring code.   Code resides in /var/www/html/ and the version of your moodle is 1.9.x

Using Git: “side load”

cd /var/www/

git clone git://git.moodle.org/moodle.git htmlgit

cd htmlgit

git branch –track MOODLE_19_STABLE origin/MOODLE_19_STABLE

git checkout MOODLE_19_STABLE

To see if you are tracking/checked out the 1.9:

git branch -a

The * should be next to the 1.9 branch.

chown apache:apache * -R

We are still in htmlgit.  Now the side load.

cp -rp .git .gitignore .gitattributes ../html/

The above copies (cp) recursively (-r) and preserves (-p) .git (the hidden .git directory and the hidden .gitignore and .gitattributes files up on level (out of htmlgit) and into html … where the moodle code resides.

Now we check the active code directory …

cd ../html/

ls -ld .git (is .git there?)

Now we check which branch it’s tracking.

git branch -a

Should show us:

* MOODLE_19_STABLE
master

with other versions of Moodle under ‘master’.

To make sure git understands issue the following while in /var/www/html/

git reset –hard

The above should result in something like:

Checking out files: 100% (18560/18560), done.
HEAD is now at [lettersnumbers] release 1.9.20+

You are now ready to update the 1.9.x code to the highest 1.9.x version available.

This is a one time thing … using git from this point forward will take place in the code directory of moodle with other git commands.

You can also remove the /var/www/htmlgit directory we used to side load as it is just taking up space now.

 

 

Leave a Reply