This depends on the university so you need to ask them.
To have a degree granted from a university you need to fulfill their requirements. But you may be given credit for things you have already completed. So if the university you are moving to recognizes your quals to be equivalent to theirs then you don’t have to pass them again. Same with course requirements.
Make sure you find out all the conditions are for the university you are moving to are. When I was at grad school a professor joined the department from a different university and brought almost all her students. However the ones who were within 1 year of graduating (ABD) were not allowed to transfer and would get their degrees from their previous university which was fine since they were the same tier or school. But while finishing up their work at the new department they could not be considered students and so couldn’t receive the same benefits package that students did including access to the student clinic. For the younger students who were allowed to transfer, they didn’t get on-campus housing priority like all new students would… and this was in a very high cost of living area where it’s really hard to find off-campus housing that’s affordable on a grad student stipend.