You're probably more familiar with Redshift as its talked about quite a bit. When something is moving away from something else, the light that is emitted is predominantly at the red end of the spectrum. Red light wavelengths tend to be more stretched out the futher you are from the object.
Blue light wavelengths tend to be closer together. Blueshift light tends to be emitted from objects that are moving closer. By looking at the blue and red shift, we can determine whether the object is coming closer to us such as in the case of the Andromeda galaxy or moving away from us. By looking at the spectrum of the objects light, it is also possible to determine how far away the object is by the stretched nature of the spectrum. The further away, the more red the lights spectrum has.
In the case of the Andromeda Galaxy, it has been discovered that it moving closer to us, at about 75 miles per second which may seem fast but duie to the sheer distance between our galaxy and the Andromeda Galaxy means they won't collide for another four billion years so we're safe
Scientists use spectrographs to look at the colour spectrum of the light from the star to determine the characteristics. Looking at a star's spectrograph can also tell what its made of and the metals that are in the star and therefore estimate its age amongst other things.
Red and Blueshifts subject originated from the Doppler Effect, the effect that describes an instrument that is played at the same volume constantly will appear getting loud as it gets closer to an object and quieter as it moves away. In addition to sound doppler waves, he also applied the theory to light waves. It was the light doppler effect that led ultimately to the Big Bang Theory that is the theory about the beginning of the universe. When Edwin Hubble noticed that the galaxies were moving away from us, the big bang theory started to take off. If they were moving away, they should have all been close, very close, as close as a an atomic singularity.