The answer to that question, like many answers to questions about bankruptcy, is "it depends". As an overview, it depends on the equity you have in your home and the "exemptions" you have to protect your home from creditors. For starters, "you" would never have to sell your home, but the bankruptcy trustee might do that.
Equity in your home – Your equity for bankruptcy purposes, or the amount that creditors would get (not considering exemptions), is the current market value of your home less the total amount you owe on it, less another approximately 10% for cost of sale and another approximately 10% for the trustee's fee. If that's a positive number, you need to protect it using the exemptions available.
Exemptions – In California you get a homestead exemption of $300,000 (minimum) to $600,000 (maximum) depending on the county you live in.
This whole subject is both complex and very important, so please retain a qualified bankruptcy attorney so you're assured of the best possible outcome.
For a free consultation, click here or call 415-342-4666