Quite sure you are right, unless my memory is failing sitewide github search of codebases required a login. Searching for repo names without login was ok though.
Possibly it was only enforced for very generic search queries returning thousands of results but it has been around a long time, Github acquisition was only in October 2018.
Sitewide code search has been used to find AWS keys and other secrets people have accidentally uploaded. The login requirement is so they can set meaningful rate limits.