  Massive steam and CO$_2$ atmospheres have been proposed for magma ocean
outgassing of Earth and terrestrial planets. Yet formation of such atmospheres
depends on volatile exchange with the molten interior, governed by volatile
solubilities and redox reactions. We determine the evolution of magma
ocean--atmosphere systems for a range of oxygen fugacities, C/H ratios and
hydrogen budgets that include redox reactions for hydrogen (H$_2$--H$_2$O),
carbon (CO--CO$_2$), methane (CH$_4$), and solubility laws for H$_2$O and
CO$_2$. We find that small initial budgets of hydrogen, high C/H ratios, and
oxidizing conditions, suppress outgassing of hydrogen until the late stage of
magma ocean crystallization. Hence early atmospheres in equilibrium with magma
oceans are dominantly carbon-rich, and specifically CO-rich except at the most
oxidizing conditions. The high solubility of H$_2$O limits its outgassing to
melt fractions below $\sim$30\%, the fraction at which the mantle transitions
from vigorous to sluggish convection with melt percolation. Sluggish melt
percolation could enable a surface lid to form, trapping water in the interior
and thereby maintaining a carbon-rich atmosphere (equilibrium crystallization).
Alternatively, efficient crystal settling could maintain a molten surface,
promoting a transition to a water-rich atmosphere (fractional crystallization).
However, additional processes, including melt trapping and H dissolution in
crystallizing minerals, further conspire to limit the extent of H outgassing,
even for fractional crystallization. Hence, much of the water delivered to
planets during their accretion can be safely harbored in their interiors during
the magma ocean stage, particularly at oxidizing conditions.
