  The current understanding of galaxy formation is that it proceeds in a
'bottom up' way, with the formation of small clumps of gas and stars that merge
hierarchically until giant galaxies are built up. The baryonic gas loses the
thermal energy by radiative cooling and falls towards the centres of the new
galaxies, while supernovae (SNe) blow gas out. Any realistic model therefore
requires a proper treatment of these processes, but hitherto this has been far
from satisfactory. Here we report an ultra-high-resolution simulation that
follows evolution from the earliest stages of galaxy formation through the
period of dynamical relaxation. The bubble structures of gas revealed in our
simulation ($< 3\times10^8$ years) resemble closely the high-redshift Lyman
$\alpha$ emitters (LAEs). After $10^9$ years these bodies are dominated by
stellar continuum radiation and look like the Lyman break galaxies (LBGs) known
as the high-redshift star-forming galaxies at which point the abundance of
elements heavier than helium ("metallicity") appears to be solar. After
$1.3\times10^{10}$ years, these galaxies resemble present-day ellipticals.
