$ cd /path/to/your/webroot
$ git clone git://git.moodle.org/moodle.git (1)
$ cd moodle
$ git branch -a (2)
$ git branch --track MOODLE_501_STABLE origin/MOODLE_501_STABLE (3)
$ git checkout MOODLE_501_STABLE
The command (1) initializes the new local repository as a clone of the ‘upstream’ (i.e. the remote server based) moodle.git repository. The upstream repository is called ‘origin’ by default. It creates a new directory named moodle, where it downloads all the files. This operation can take a while as it is actually getting the entire history of all Moodle versions
The command (2) lists all available branches.
Use the command (3) to create a new local branch called MOODLE_311_STABLE and set it to track the remote branch MOODLE_311_STABLE from the upstream repository.
The command (4) actually switches to the newly created local branch.
Updating Your Installation #
$ cd /path/to/your/moodle/
$ git pull