A nuke would be like a firecracker in the vacuum of space. With no air to cause a shockwave, the only effects would be heat, radiation, and a small amount of shrapnel. No matter what the movies tried to portray, I don’t think nuclear warheads are the answer to an incoming asteroid. It will have to be a kinetic impact, which means a lot of time needed before impact with the Earth in which to nudge it off course.
Like a pea shooter hitting a brick wall, unless we have some magical tractor beam or massive phaser beam device a speeding asteroid is going to go where it’s orbit takes it and mankind is virtually powerless to stop or move it. Reality ensues