Can a custom license forbid forking?

I’m sorry if this is posted in the wrong location.

Well I noticed some project that I feel is going in the worse direction. - So I wish to fork it and move it in a direction that I feel is more beneficial.

However I then notice there is a license that basically says: “You cannot fork this project, and any code submitted is explicitly owned by me”. This seems to be against the open source culture of github, it also reduces the chance on a fork as the original creator strongly dislikes my suggestion.
So is such a license even allowed in public repositories?

If it is I’d just have to rewrite everything at some point - Not something I’d like to do as the codebase isn’t trivial.

You could surely find some useful information here:

https://opensource.guide/legal/

And I am not a lawyer, however I think that it is allowed. I mean, it would make sense to me since just putting your work out in the open does usually not mean that you give everyone the right to do things with it.

However, if this is really a big thing for you, you might want to seek real legal advice.

Thanks for the question.

The GitHub Terms of Service state the default license granted to other users of public repos, beyond that we don’t comment on hypothetical questions about the terms of service. If you have questions about copyright or open source licensing, you should contact your own legal counsel.

I hope that helps!