When galaxies move farther away the wavelength of the light is longer causing the galaxy to shift red but if it moves closer, the wavelength of the light gets smaller causing the galaxy to blue shift. The reason that the wavelength increases or decrease is due to the doppler effect.