Previous simulations of the growth of cosmic structures have broadly reproduced the cosmic web of galaxies that we see in the Universe, but failed to create a mixed population of elliptical and spiral galaxies due to numerical inaccuracies and incomplete physical models. Moreover, because of computational constraints, they were unable to track the small scale evolution of gas and stars to the present epoch within a representative portion of the Universe. Here we report a simulation that starts 12 million years after the Big Bang, and traces 13 billion years of cosmic evolution with 12 billion resolution elements in a volume of $(106.5,{rm Mpc})^3$. It yields a reasonable population of ellipticals and spirals, reproduces the distribution of galaxies in clusters and statistics of hydrogen on large scales, and at the same time the metal and hydrogen content of galaxies on small scales.