Creating a new car produces massive amounts of carbon pollution.
For a mid-sized average sedan the pollution created from finding and smelting ore to the massive amounts of energy and water required during production it takes around 45/50k miles just to offset production alone, and that's assuming the new car does not use any energy.
Add to this that producing batteries is even much more taxing on the planet both in terms of resources and toxicity.
Add to this yet another thing: unless the energy that's produced wherever you recharge your car isn't coming from renewables the gains in pollution are further limited.
So, to conclude: unless you commute a lot, plan to keep your car for a long time and you live in an area where there is a huge % of renewables the, by far greenest solution is to buy a used car or keep your one, even if it has an old polluting engine, it's gonna pollute much less than producing a new car and using gas and coal to power it