Urgent question

I introduce my self first my name is ahmed 29years old guy married i came to germany last year with a marriage visa and i started studying last semester in university, but right now my marriage is falling apart my wife is really making it hard for me and she wants to divoce me, but i dont want to because if i do i will not be able to persue my study and i will be deportated to my home country algeria, but i have heard that if someone is studying they cannot deportat him so i am here to ask for legal advice, i cant lose my wife and my study, i dont want to but i think its gonna happen so i need advice how to be able to stay at least as a student.
i am gratful for your advices

I assume you are here on a family reunion (not marriage!) visa. You need to stay in the marriage for three years before you can get your own visa to continue staying even without her.
If you cannot rescue the marriage until thatz time, you could try to get a student visa instead. Otherwise you must leave Germany, as it is illegal to stay on without valid visa.

thank you for your fast answer, so can i apply for a student visa with my student identity? in Auslanderbehoerde? or should i return to algeria and apply again?

my residency is familly reunion, but when i got visa it was only for marriage because i married here in germany

You should contact the foreigner office (Auslaenderbehoerde) to ask if and how you could change to student visa.
Or maybe you could try to treat your wife better, so she doesn't want a divorce (which will cost a lot of time, trouble and money!). An intercultural counselling can do wonders (and cost a lot less).

you are right but i believe the problem doesnt come from me and of course i am trying to make thinks better but its complicated however i thank you for your answer again