there are two problems we need to solve:
1. github is not the repo only. It is an ecosystem for developing projects with bug tracking, issues, voting, comments, reviews, etc.
To create a decentralized clone of github you'll need to reproduce all that features.
2. to create a distributed decentralized repo hosting you need to create a storage with multiple times duplicated data. GitHub is free for opensource projects and paid features for private projects. How that can be reproduced in distributed ecosystem?
We have been discussing on works about your first statement.
On your second statement, a way to do so that would allow it to remain free is to identify the users. You would not be able to do so freely in current eco-systems. To allow it to remain free for the mass is to have a decentralized identity system in place, better than an email, this would be the only way to freely control spam. The good in such system could be that we are only storing text and in many cases this does not amount to much space, meaning that just to store a file on a users end would not technically be a problem. A way to further decrease space per user is to shard. Block rewards in a free eco-system in where money is still coming in through premium features would allow those storing to reap financial rewards. Still there could be a eco-system in where no money comes in just a blockchain without cryptocurrency in where you have to opt-in to store information from other users to be able to have others store information for you.
Really the biggest goal to allow it to remain free and this goes for every platform is to tackle decentralized identity.
Update
Now that I think about it a nice way to reduce spam without decentralized identity which would be possible to have been in use as of yesterday is to further develop the system in which I spoke of secondly, a you store for me I store for you type system. This would defeat spam in a sense if further looked into such as only allowing to decentrally store what you are decentralizing for others, so if I have 50gb in which I am storing files for others then I am allowed a cap of 50gb in which others can freely store for me in a decentralized manner, this would make everything neutral.