I'm Ukrainian and I hold valid polish residence permit. However, I got accepted for the graduate study program in Germany, which lasts more than 6 months. Am I allowed to enter Germany using polish temporary residence permit and apply for german residence permit after entering? Or am I obligated to apply for german visa in order to enter Germany for study purposes?
No, you have to apply for a German student visa before you move to Germany. If you cross the border and try to get a Residence permit, you will be denied one as the paperwork in the German side is not available, since you didn't apply for a visa.
Getting a German visa inside the EU should not take long (around 2-3 weeks).
Additional information from here: https://polen.diplo.de/pl-de/03-service/03-02-visainfo-en/visum-brauche/478860
As long as you are not a citizen of a country whose citizenship allows you to enter Germany freely (please check the list of states below), you are residing legally in Poland (e.g. Karta pobytu, D-Visa) and you plan to stay in Germany for more than 3 months (family reunion, studying) or to work in Germany, you need a visa for entering the country.