You can apply for a German visa basis the duration of the course.
Any course of 3 months should get – a Schengen Visa. Over 3 months should get – the German National Visa.
Students entering Germany with a national visa have to extend their stay with a resident permit in Germany for higher education from the Foreign Office. You need to do this when the entry visa is valid.
Make sure to go through the list of documents while applying for a visa.
You can go through the step-by-step guide: How to apply for a German Visa?