There are many things scientists can do to deflect an approaching asteroid. The most important thing would be having enough time to do it, since it could take many months or even years to get it working. However, most asteroids that are dangerous can be seen way in advance. Unfortunately, there are some that can appear quickly that was never tracked, but that is more of a rare thing.
The key would be changing the path of it by hitting it with something. You can either hit it was something huge, like an atomic bomb, or go with a smaller object traveling very fast to get the safe effect. If you catch it early, you only need to nudge it a tiny amount for it to miss the earth. Scientists have already landed a probe on a comet (Rosetta mission) just this year. I think they are preparing already in case one comes heading for us.