Is it safe to use copper and galvanized pipes on the same fitting?

No, you cannot join copper and galvy directly. A brass fitting needs to be between the two to prevent electrolysis. You could also use a special type of union that has a gasket between the two halves. It is called a Dielectric union. If this junction is between pipes on your water heater and the cold water supply line, you could use a fitting made for that that also is a back flow preventer (ie a check valve).