  We develop a model to describe the evolution of the intra-cluster X-ray
emitting baryons, as they are included in the dark matter potential wells of
galaxy clusters evolving through subsequent merging events in the framework of
hierarchical clustering. The gas is assumed to re-adjusts to a new hydrostatic
equilibrium after each merging event. Before merging it is gravitationally
heated at the local virial temperature when bound in subclusters; at early $z$
the gas is preheated by supernova activity following star formation. In detail,
we compute analytically the following steps: the dynamic histories of dark
matter halos with their merging events; the associated infall of gas into a
halo, with compressions and shocks estabilishing the conditions at the cluster
boundary; the updated disposition of the gas in the potential well matching
such conditions; the statistical convolution of the key quantities over the
merging histories. The model predicts the density and surface brightness
profiles with no free parameters; the so-called $\beta$ parameter is itself an
outcome of the model, and the polytropic index $\gamma$ is internally
constrained to a narrow range. We obtain declining temperature profiles, and
profiles for the density and for the surface brightness shallower in groups
compared with clusters. Our model groups also contain a lower baryonic fraction
on average, but with a scatter considerably larger than at cluster scales.
Various statistics are obtained analytically upon averaging over the merging
histories. In particular, we predict in different cosmologies the statistical
correlation $L-T$ of luminosity with temperature; similarly we derivethe
correlation $R_X-T$ for the size of the X-ray emitting region. The intrinsic
scatter in both correlations is also predicted.
