Simply viewing and reading the source code is not illegal unless if you personally have made a binding agreement with GitHub in which case it would be a civil matter. Or if you profit off of it then you could be liable.
Viewing classified top secret nsa documents is not illegal unless you have agreed to never viewing them when gaining classified clearance. Anyone who does not have classified clearance is free to look at them.
You are not liable for what you read. Those posting it may be liable for infringement, and you could be liable if you infringement upon it. But reading is not yet illegal in the usa.
GP didn't ask about liability for reading it but rather the legality of intentionally retaining a local copy. Intentionally making a copy of content which you know you don't have a license for is against copyright law in all western jurisdictions that I'm aware of.
Reading something isn't inherently illegal itself, true. I'm fairly certain that intentionally navigating to a website that you know contains pirated content is a violation of copyright law though. (Of course no one is going to bother prosecuting you for it, but still.)
Its a bit more complicated than that because US has exceptions (i.e. fair use) to copyright law for research and educational purposes (but the rules for how and when the exceptions apply are pretty complicated and vauge)
Viewing classified top secret nsa documents is not illegal unless you have agreed to never viewing them when gaining classified clearance. Anyone who does not have classified clearance is free to look at them.
You are not liable for what you read. Those posting it may be liable for infringement, and you could be liable if you infringement upon it. But reading is not yet illegal in the usa.