Before you do anything major in Moodle, it is always a good idea to verify where you are starting from, which you can do with the command it status:
timslaptop:moodle tim$ git status
# On branch MOODLE_23_STABLE
nothing to commit (working directory clean)
If it does not day working directory clean, then it will give you more details about what has been modifed compared to the standard Moodle code, and you should investigate that before proceeding.
Once you are ready, use the command git fetch to make sure you have the latest code from the moodle server:
timslaptop:moodle tim$ git fetch
remote: Counting objects: 8808, done.
remote: Compressing objects: 100% (2002/2002), done.
remote: Total 6543 (delta 4920), reused 5881 (delta 4332)
Receiving objects: 100% (6543/6543), 1.42 MiB | 636 KiB/s, done.
Resolving deltas: 100% (4920/4920), completed with 880 local objects.
445b4dd..6ccbbe5 MOODLE_21_STABLE -> origin/MOODLE_21_STABLE
33ba005..a1a63ea MOODLE_22_STABLE -> origin/MOODLE_22_STABLE
7d2c5cd..bbcf8da MOODLE_23_STABLE -> origin/MOODLE_23_STABLE
4c7e6ea..09de5eb MOODLE_24_STABLE -> origin/MOODLE_24_STABLE
2075186..1dd6835 master -> origin/master
Then, you can use git checkout to switch to the new branch.
timslaptop:ddwtos tim$ git checkout MOODLE_24_STABLE
Branch MOODLE_24_STABLE set up to track remote branch MOODLE_24_STABLE from origin.
Switched to a new branch 'MOODLE_24_STABLE'
However, sometimes it does not guess what you mean, in which case you have to type the full command
git checkout -b MOODLE_24_STABLE --track origin/MOODLE_24_STABLE
Which will give the same output as before. At this point, you will have the latest Moodle 2.4.x code, and git pull in future will update it.