The present structure of galaxies is governed by the radiative dissipation of the gravitational and supernova energy injected during formation. A crucial aspect of this process is whether the gas cools as fast as it falls into the gravitational potential well. If it does then rapid normal star formation is assumed to ensue. If not, and the gas can still cool by the present time, then the situation resembles that of a cooling now, such as that commonly found in clusters of galaxies. The cooled matter is assumed to accumulate as very cold clouds and/or low-mass stars, i.e. as baryonic dark matter. In this paper we investigate the likelihood of a cooling-flow phase during the hierarchical formation of galaxies. We concentrate on the behaviour of the gas, using a highly simplified treatment of the evolution of the dark matter potential within which the gas evolves. We assume that normal star formation is limited by how much gas the associated supernovae can unbind, and allow the gas profile to flatten as a consequence of supernova energy injection. We find that cooling flows are an important phase in the formation of most galaxies with total (dark plus luminous) masses greater than or similar to 10(12) M., creating about 20 per cent of the total dark halo in a galaxy such as our own and a smaller but comparable fraction of an elliptical galaxy of similar mass. The onset of a cooling flow determines the upper mass limit for the formation of a visible spheroid from gas, setting a characteristic mass-scale for normal galaxies. We argue that disc formation requires a cooling-now phase and that dissipation in the cooling-flow phase is the most important factor in the survival of normal galaxies during subsequent hierarchical mergers.