In the 1800s astronomers began to light from the Sun through a diffraction grating, which allowed them to view the Sun’s spectral lines. Thus began an area of astronomy known as spectroscopy. As the technology advanced enough to look at the spectra of stars, we were finally able to categorize stars by not just their temperatures, but by the elements contained in their atmospheres. We could also use the shift of these spectra due to the Doppler effect to determine a star’s motion. With modern telescopes we can do the same for galaxies using a method known as long-slit spectroscopy.
The idea of long-slit spectroscopy is to only observe the spectrum of an object along a narrow line. In the case of galaxies, this is typically along its long edge when a galaxy is viewed from mostly edge on. In this way we can look at the spectrum all along a galaxy. Because spectral lines are shifted toward the red or blue due to the motion of the source, the rotation of a galaxy gives a spectral line a shift. From this we can determine the motion of stars in the galaxy. This allows us to study things such as dark matter, which can affect the motion of stars.
Long-slit spectroscopy also allows us to study things such as the evolution of galaxies over time, and how the composition of stars can vary based upon their distance from the galactic core. Given how faint galaxies are compared to many stars, it’s actually a pretty amazing type of astronomy.