Radiation from most of the galaxies shows a red shift and this points to the fact that they are receding from our galaxy, the Milky Way. But there are some other galaxies like the Andromeda Galaxy (M31), part of our local group, which is moving towards the Milky Way, as is evident from the blue shift in the radiation from the Andromeda Galaxy. (See the article on Spectra for more information about blueshift.) Thus, the Milky Way is under a collision threat from the Andromeda galaxy.
Currently, Andromeda is at a distance of 2.3 million light years from the Milky Way and it will take millions of years for this merger. The future of the Earth and the Sun after this merger is interesting to imagine. Scientists believe that there is a possibility for the relocation of the Earth, but they dismiss the chances of a collision between stars in the Andromeda and the Earth. This is because the stars in the galaxies are far apart and the chances of the Earth and the Sun colliding with a star in the Andromeda galaxy is minimal. Even though scientists have estimated the speed with which these galaxies are approaching as 120km/sec, they are unable to measure accurately the sideways speed of the Andromeda Galaxy. If the sideways speed is more than what they have calculated, then there is a chance that this collision will never happen.