It's not a foregone conclusion that parents move into separate households the minute they decide to divorce; many remain in the marital home together. If you decide to part ways, custody and visitation can become an issue long before your divorce is final. You generally cannot take your children and leave without a court order giving you permission to do so, but you can reach an arrangement by consent or the court can issue one after a hearing. Either way, if your situation changes after the order is in place, you have a few options for modifying it.
A temporary custody order governs issues regarding your children during the divorce process. The court typically won't order or sign off on a permanent custody arrangement until your case is over, at which time it will include the terms in a final judgment or decree. If changes occur during this period that make the temporary order unworkable, and you and your spouse are in agreement as to what to do about it, you can submit a consent order to the court. When the judge signs it, it will override the terms of the first order until your divorce is final. Otherwise, you must usually file a motion with the court, asking the judge to reevaluate the custody terms in light of the new situation. The court may not be willing to order a modification of temporary custody terms, however, unless the changes are substantial. Temporary orders are always subject to modification in your final decree anyway, so unless something significant has occurred – such as the custodial parent moving out of state or being sent to prison – there's typically no urgency about immediately issuing another one.
If you and your spouse are not in agreement regarding how to alter your temporary custody arrangement, you can try mediation to attempt to reach a compromise. In some states, mediation is a mandatory aspect of all divorces that involve children, so you may have to attend anyway. Mediation involves a trained, neutral third party who tries to help parents find a middle ground that benefits their children. If you reach an agreement in mediation, you or the mediator can submit it to the court so a judge can sign it into a temporary order or even include it as a permanent parenting plan in your eventual decree or judgment.
If the changes are serious and they threaten the health or well-being of your children, most states have procedures in place that allow you to file for emergency custody. You might be able to do this even without notification to your spouse that you're asking the court to intervene. The rules can vary from jurisdiction to jurisdiction, but you must usually establish that something dire has occurred and your children will be endangered if the court does not immediately change the terms of your temporary order. Frivolous or false accusations usually don't pass muster with a judge, and they can get you in a good deal of trouble, so you might want to speak with an attorney first to make sure you have viable grounds for requesting emergency relief.
If all else fails and you can't change your temporary custody order before your divorce is final, you'll have to litigate custody as part of your final divorce trial. Permanent, ongoing custody arrangements are ordered at this time. If you and your spouse can't reach a resolution on your own, it's not uncommon for the court to order a custody evaluation or even appoint an attorney to represent your children in the proceedings. You'll effectively leave it up to a judge to determine what sort of custody arrangement is in the best interests of your children.