The key to working with the Moodle git repository (https://docs.moodle.org/31/en/Git_for_Administrators) is to look at changes to the
version.php file in the main moodle directory which tells you the moodle version.
You can use the whatchanged git command to get a summary of all changes and tags.
git whatchanged -p version.php
But more than likely if you are upgrading or patching you want to find a specific Moodle version. For example, I want to find the commit that relates to “Moodle release 3.1.2” which has the following in the version variable:
To find that use whatchanged to search for that value like so:
git whatchanged -p -S2016052302.00 version.php
This gets you the results that revolve around that version change, e.g. perhaps you want the change from version v3.1.1 to v3.1.2.
Once you have the commit hash e.g. f851201 you can then checkout that hash for example to see that specific version. Make sure you confirm you have what you need by looking at
git checkout f851201-B moodle