Earth likely acquired a significant fraction of its volatile elements during the main stages of accretion. The atmospheres of the planetary embryos that accreted to form Earth must therefore have survived the giant impacts (collisions between planet-sized bodies) that dominate the end of accretion. Using numerical simulations of giant impacts, I will show that the efficiency of atmospheric loss depends strongly on the surface conditions on the colliding bodies (e.g., atmospheric pressure, presence/absence of an ocean). Understanding the complex feedbacks between the evolution and survival of planetary atmospheres provides new insights into the origin of our atmosphere and ocean.