Use a dielectric union and a relative short brass nipple. The nipples go from the new water heater to the brass side of the unions. The steel side of the union obviously goes to the galvanized pipe. This little gizmo stops galvanic corrosion from joining 2 dis-similar metals.
I use a little pipe dope but I have used teflon tape. Whatever you like best to make a water tight seal.
now for the interesting part of this answer…
There are some areas of where I live, Midwest USA, that require water heaters to be installed by only licensed plumbers. Please keep this in mind if you are using gas as the heat source.