  We address the origin of the robust bi-modality observed in galaxy properties
about a characteristic stellar mass ~3x10^{10}Msun. Less massive galaxies tend
to be ungrouped blue star-forming discs, while more massive galaxies are
typically grouped red old-star spheroids. Colour-magnitude data show a gap
between the red and blue sequences, extremely red luminous galaxies already at
z~1, a truncation of today's blue sequence above L_*, and massive starbursts at
z~2-4. We propose that these features are driven by the thermal properties of
the inflowing gas and their interplay with the clustering and feedback
processes, all functions of the dark-matter halo mass and associated with a
similar characteristic scale. In haloes below a critical shock-heating mass
M_shock~10^{12}Msun, discs are built by cold streams, not heated by a virial
shock, yielding efficient early star formation. It is regulated by supernova
feedback into a long sequence of bursts in blue galaxies constrained to a
"fundamental line". Cold streams penetrating through hot media in M>M_shock
haloes preferentially at z>2 lead to massive starbursts in L>L_* galaxies. At
z<2, in M>M_shock haloes hosting groups, the gas is heated by a virial shock,
and being dilute it becomes vulnerable to feedback from energetic sources such
as AGNs. This shuts off gas supply and prevents further star formation, leading
by passive evolution to "red-and-dead" massive spheroids starting at z~1. A
minimum in feedback efficiency near M_shock explains the observed minimum in
M/L and the qualitative features of the star-formation history. The cold flows
provide a hint for solving the angular-momentum problem. When these processes
are incorporated in simulations they recover the main bi-modality features and
solve other open puzzles.
