Formation of Galaxies in a Hierarchical Clustering Model