chosch amadid and thanks for sharing your extraordinarily important question with us.
The normal procedure to achieve your goals would be to finish your MA programme (with good marks). Afterwards you will be granted a 18-months-visa for finding a position according to your qualifications. Whether you will be successful in finding such a job largely depends on your subject, your language skills and your adaptability. E.g., if you hold a superb degree in sociology from the University of Hamburg, you should not notwithstanding be prepared to move to Regensburg to earn your living as a refugee counsellor there. (This will be accepted as "according" by the immigration authority).
Depending on your integration efforts (very good command of German, voluntary work an do on) you can apply for the German citizenship after 6 years, which would enable your wife to join you for the purpose of family reunification.
The crucial point are these months after your graduation. If you, e.g. after 120 applications and some 12, 13 moths of intense job hunting, have to realize that you won't meet the requirements of the immigration office, you could consider an asylum application. During this procedure, which can take several years, your wife cannot join you.
Please note that that asylum applications are easily rejected if you don't deliver serious reasons and proofs, for example: If you had been working in a micro-funding NGO for women in Northern Afghanistan and therefore received death threats from the Taliban, you should a least show up with a copy of your contract with that NGO:
I would recommend you to start job hunting some months before graduation and to get your CV and application checked by an expert. You could also attend workshops about the german labour market at your university (one programme is called "Student und Arbeitsmarkt").
As so much depends on your subject and your language skills and so many aspects are still open to discussion, i would love to hear a bit more from you, but i won't ask you any personal details here. If you wish, you can drop me a few lines with some background information on MBEON (www.mbeon.de), which is a secure messenger system.
I hope the information given so far was useful for you. Don't hesitate to contact me again.
Best wishes so far