  We quantify the atmospheric mass loss during planet formation by examining
the contributions to atmospheric loss from both giant impacts and planetesimal
accretion. Giant impacts cause global motion of the ground. Using analytic
self-similar solutions and full numerical integrations we find (for isothermal
atmospheres with adiabatic index ($\gamma=5/3$) that the local atmospheric mass
loss fraction for ground velocities $v_g < 0.25 v_{esc}$ is given by
$\chi_{loss}=(1.71 v_g/v_{esc})^{4.9}$, where $v_{esc}$ is the escape velocity
from the target. Yet, the global atmospheric mass loss is a weaker function of
the impactor velocity $v_{Imp}$ and mass $m_{Imp}$ and given by $X_{loss} ~
0.4x+1.4x^2-0.8x^3$ (isothermal atmosphere) and $X_{loss} ~ 0.4x+1.8x^2-1.2x^3$
(adiabatic atmosphere), where $x=(v_{Imp}m/v_{esc}M)$. Atmospheric mass loss
due to planetesimal impacts proceeds in two different regimes: 1) Large enough
impactors $m > \sqrt{2} \rho_0 (\pi h R)^{3/2}$ (25~km for the current Earth),
are able to eject all the atmosphere above the tangent plane of the impact
site, which is $h/2R$ of the whole atmosphere, where $h$, $R$ and $\rho_0$ are
the atmospheric scale height, radius of the target, and its atmospheric density
at the ground. 2) Smaller impactors, but above $m>4 \pi \rho_0 h^3$ (1~km for
the current Earth) are only able to eject a fraction of the atmospheric mass
above the tangent plane. We find that the most efficient impactors (per unit
impactor mass) for atmospheric loss are planetesimals just above that lower
limit and that the current atmosphere of the Earth could have resulted from an
equilibrium between atmospheric erosion and volatile delivery to the atmosphere
from planetesimals. We conclude that planetesimal impacts are likely to have
played a major role in atmospheric mass loss over the formation history of the
terrestrial planets. (Abridged)
