When we find an asteroid or comet that has a high probability of hitting the Earth we have a number of options open.
Evacuate / Ride the Storm
Given enough warning, and an accurate ground-zero prediction (both entirely feasible), it might be possible to evacuate the point of impact and areas in danger such as low-lying coastal regions. This might be an adequate course of action for small impacts (with local or regional effects), but for larger, globally threatening events, long term protection and supply will be necessary for any surviving population – it might be a case of “out of the frying pan, into the fire”.
The possibility of destroying potential impactors, probably with high yield nuclear weapons, has been studied in some detail. With the current lack of detailed knowledge of the exact composition of particular objects, and their structural strength, there is an element of doubt as to the effectiveness of this course of action. The fear would be that incomplete disruption of the object would subject the Earth to multiple impacts from pieces of the original body. The effects of transforming a cannon ball into a cluster bomb could be more far-reaching than the original threat.
Deflection / Acceleration / Deceleration
Assuming that a potential impactor can be identified early enough, its orbit could be modified sufficiently to ensure that an impact would not occur. Methods considered include the use of gravity, by parking a spacecraft close to the body and then moving it away, relying on the mutual gravity to change its orbit, or the use of propulsion units or mass drivers (using the material of the object itself as fuel) to physically drive it from its path. Only very small adjustments would be required to ensure a miss rather than a hit.