Problem with a cheater supervisor I am a third-year PhD student in Germany, and I have some issues with my supervisor. 

To make a long story short, he does not read my research drafts but instead, he asks us to review papers he takes from conferences as a reviewer, and then he submits them with his name to make a reputation. 

He also bans me from writing my thesis. Other students in the past including master students have had similar problems regarding their master thesis. And recently a PhD student quit after 3 years of working in his group and a few other cases in the past. 

Anyways, the main reason I am writing this is that about two years ago he asked me to work on a remote project (with another group remotely) to have a joint research paper. After doing all the things that he and the remote professor ask me to do, my so-called supervisor now does not allow me to write my paper based on the result of this research, and I found that he (and the remote guy) are replacing me with another student on this project and are ignoring all of my works. I have been working on a private repository in GitHub, but I do not have a master user. 

What are the possible solutions in this case? How can I defend my rights? Is there any way to collect evidence from the repository or emails? Can I bring these people to court?

I have tried to talk to my supervisor many times, and it doesn't work. Also, the head of our department does not want to involve himself in these jobs.

This is an update to the answers and comments below:

Thank you guys! I need to write this long response to Buffy and other people comments:
 Indeed I am looking for a proper advisor. However, for now, I want to get my paper published (the remote project). Even though I must change my supervisor, still I devoted 2 years of my life on this work. So, I think it's my right to have this paper in my CV even if they write the paper separately.

It was a kind of deal between my so-called supervisor and me and his friend (the remote professor) to have a paper in the end.


How can I collect proofs regarding all the ideas and technical works I have been putting in this project? (for example, has Github any option in these situations? )
Can I write an abstract about this project with some details and upload it somewhere like Arxiv or Researchgate. Does it force them to put my name at least as a co-author for the paper?
Having some screenshots or recorded screen from the history of the repository can be helpful? (in case they kick me out of the git repository ) 
Is there any international, Europian or American student association or similar things to help people like me?
I'm surprised that you have found any reasons to stay. I don't predict that you can have any happy future if you stay in this situation. There is clearly a lack of respect, maybe both ways. 

I can't think of any path to success whatever if you stay. Even if you can force better behavior, the resentment will come back to hurt you when you are ready to move on. I wouldn't expect any decent letters of recommendation. 

None of what you describe is proper. I hope it is uncommon. 

Find a better situation, even if you need to change universities. The head's lack of interest may make staying also impossible. 

Unfortunately, this advice comes with a heavy cost since moving will be difficult and you may not be able to take your research with you. The less developed it is, probably the easier it is to carry it away and continue. But you need a supportive advisor.