  We study the formation of galaxies by using $N$-body/hydrodynamics
simulations to investigate how baryons collect at the centre of dark matter
halos. We treat the dark matter as a collisionless fluid and the baryons as an
ideal gas. We include the effects of gravity, pressure gradients,
hydrodynamical shocks, and radiative energy losses, but we neglect star
formation. Our initial conditions assume a flat universe dominated by cold dark
matter with a mean baryon abundance of 10\% by mass. Typical halos form through
the merging of a few smaller systems which had themselves formed in a similar
manner at higher redshift. The gas collects at the bottom of dark matter
potential wells as soon as these are properly resolved by our simulations.
There it settles into cold, tightly bound disks, and it remains cold during
subsequent evolution. As their halos coalesce, these disks merge on a timescale
that is consistent with dynamical friction estimates based on their {\it total}
(gas + surrounding dark matter) mass. Both the merger rates of the disks and
their mass spectrum are in remarkably good agreement with recent analytic
models that describe the evolution of {\it dark halos} in a hierarchical
universe. This very simple model of galaxy formation suffers from serious
shortcomings. It predicts that most baryons should be locked up in galaxies,
whereas in the real universe most baryons are thought to lie outside visible
galaxies. In addition, it predicts the specific angular momentum of a disk to
be only about 20\% that of its surrounding halo, corresponding to a radius
smaller than that of observed spiral galaxy disks.
