A common misperception is that the DEED determines who is responsible for the home. The actuality is knowing who is responsible for the LOAN. I've seen situations where someone did a quit claim to put the deed into someone's name...but it didn't absolve them of the responsibility to make the loan payments. Your spouse would have had to finance you out of the loan so that you were not on it anymore to make certain you weren't affected. Mind you, this does not take care of the bankruptcy issue because usually you won't be given a loan until you are 2 years beyond your discharge date UNLESS you have a Chapter 13 and have done very well in making your payments and can receive permission from the court to buy a house (I only learned of that, via experience, a couple of years ago).
You do still have options like finding a seller who is willing to do owner-financing or a lease-purchase wherein you use the lease time to bring up your credit scores and wait the necessary time from your discharge date. Please feel free to give me a call at 816-213-9362 to discuss your situation further so that any advice I am able to pass on is more geared to your particular situation rather than a more broad-brush approach.
Ed Rippee, CSP, WHS, CDPE