The formation of galaxies and the evolution of stars