Never use galvanized pipe for water. It will eventually rust. Local codes differ, so you need to check with your local authorities, but in my area the standard connection is a dielectric nipple or a brass nipple followed by a short length of flex copper tubing connected to the supply line. Same on the hot side. You may also need to strap the tank to the walls if you are in an earthquake zone.