The first-order monoclinic-to-orthorhombic (beta-->gamma) phase transition of the giant magnetocaloric material Gd(5)Si(2)Ge(2) was studied using in situ high-temperature single-crystal X-ray diffraction. A special crystal mounting procedure was developed to avoid crystal contamination by oxygen or nitrogen at high temperatures. The elastic beta-->gamma transformation occurs at 300-320 degrees C during heating, and it is reversible during fast and slow heating and slow cooling but irreversible during rapid cooling. Contrary to theoretical predictions, the macroscopic distribution of the Si and Ge atoms remains the same in both the orthorhombic gamma-polymorph and the monoclinic beta-phase. It appears that interstitial impurities may affect stability of both the monoclinic and orthorhombic phases. In the presence of small amounts of air, the beta-->gamma transformation is complete only at 600 degrees C. The interslab voids, which can accommodate impurity atoms, have been located in the structure, and an effect of partially filling these voids with oxygen or nitrogen atoms on the beta-gamma transition is discussed.