By "illegally uploaded material like ebooks" I presume is meant content uploaded without permission from the copyright owner or any authorized agent, and not under any license which permits such uploading and use.
Forking a repository means making copies of the files it contains. If the files were uploaded without a proper license or permission from the copyright holder that would be an act of infringement.
Github's documentation about forking (linked in the question) says:
A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.
Most commonly, forks are used to either propose changes to someone else's project or to use someone else's project as a starting point for your own idea. You can fork a repository to create a copy of the repository and make changes without affecting the upstream repository.
However, GitHub requires that users upload only content that the user owns or has the right to upload and license. (This means that any user who uploads unauthorized files is violating the Github terms.) Thus a forking user may be relying on that assurance from the uploading user. If the forking user is aware that the files are unauthorized (perhaps pirated) then forking is an act of knowing infringement. If the forking user is not aware, and has no reason to think that the files are unauthorized, then any act of infringement is not knowing, much less willful.
Under united-states law, infringement is actionable even if it was not knowing. See 17 USC 501, which says:
Anyone who violates any of the exclusive rights of the copyright owner as provided by sections 106 through 122 or of the author as provided in section 106A(a), or who imports copies or phonorecords into the United States in violation of section 602, is an infringer of the copyright or right of the author, as the case may be.
But under 17 USC 504 if the infringer proves that the infringement was "innocent" meaning:
... that such infringer was not aware and had no reason to believe that his or her acts constituted an infringement of copyright
Then statutory damages may be as low as $200 per work infringed.
On the other hand US statutory damages can be as high as $30,000 or up to $150,000 if willful infringement is proved. The plaintiff has the option to instead get actual damages, plus any profits made by the infringer. In some cases legal fees and costs may be added to the amount of a judgement.
The details of copyright laws will be different in different countries, but the general principles will be similar.
Thus the copyright holder could sue any user who forks a repo containing unauthorized content.
As a practical matter, a holder is not likely to sue a user who merely forked a repo with no good reason to know that the content was unauthorized. The costs of bringing such a suit would probably exceed the damages. However, if any reasonable forking user would have known or suspected that the files were unauthorized, the situation would be different, and a suit might be more likely. A takedown notice might well be served in either case. Such a notice might cause Github to delete or lock the repository.