git log -S '2018051700.00' upstream/master # OR upstream/MOODLE_35_STABLE
Will find any commit that adds or removes the given string. That gets you to a relatively narrow range of commits.
I think the $release = '3.6dev (Build: 20180524)'; line in config.php might give you even more information.
Another thing you can then use is something like
git log --pretty=%h 46574904afd39578fa..6b2e04676a6ccfe | xargs -i git diff --shortstat {}
That will show how many lines differ between each of those commits and your current code. Looking for a minimum of that might be the commit you want.