  We have obtained near-infrared imaging of 58 galaxy groups, in the redshift
range 0.1<z<0.6, from the William Herschel Telescope and from the Spitzer IRAC
data archive. The groups are selected from the CNOC2 redshift survey, with
additional spectroscopy from the Baade telescope (Magellan). Our group samples
are statistically complete to K(Vega}=17.7 (INGRID) and [3.6](AB)=19.9 (IRAC).
  From these data we construct near-infrared luminosity functions, for groups
in bins of velocity dispersion, up to 800 km/s, and redshift. The total amount
of near-infrared luminosity per group is compared with the dynamical mass,
estimated from the velocity dispersion, to compute the mass-to-light ratio,
M/Lk. We find that the M/Lk values in these groups are in good agreement with
those of their statistical descendants at z=0, with no evidence for evolution
beyond that expected for a passively evolving population. There is a trend of
M/Lk with group mass, which increases from M/Lk~10 for groups with sigma<250
km/s to M/Lk~100 for sigma=425-800 km/s. This trend is weaker, but still
present, if we estimate the total mass from weak lensing measurements. In terms
of stellar mass, stars make up ~2 per cent of the mass in the smallest groups,
and ~1 per cent in the most massive groups. We also use the near-infrared data
to consider the correlations between stellar populations and stellar masses,
for group and field galaxies at 0.1<z<0.6. We find that fewer group galaxies
show strong [OII] emission compared with field galaxies of the same stellar
mass and at the same redshift. We conclude that most of the stellar mass in
these groups was already in place by z~0.4, with little environment-driven
evolution to the present day.
