This is specific for git repos hosted on GitHub
Try the 'api' command of Github's command line app, gh, to make an authenticated call to  Github's 'get repository contents' endpoint.
The basic command is:
$gh api /repos/{owner}/{repo}/contents/<path_to_the_file>
As an added bonus, when you do this from inside a directory that contains a clone of the repo you're trying to get the file from, the {owner} and {repo} part will be automatically filled in.
https://docs.github.com/en/rest/reference/repos#get-repository-content
The response will be a JSON object. If the <path_to_the_file> indeed points to a file, the JSON will include a 'size', 'name', several url fields to access the file, as well as a 'content' field, which is a base64 encoded version of the file contents.
To get the file contents, you can curl the value of the "download_url", or just decode the 'content' field. You can do that by piping the base64 command, like this:
$gh api /repos/{owner}/{repo}/contents/<path-to-the-file> --jq '.content' | base64 -d