To generate H2 from H2O:
Electrolysis -- by applying a voltage to water, oxygen and hydrogen gas are generated.
To make H2O from H2 and O2:
Combustion -- burning hydrogen gas in oxygen results in pure water and heat!
Fuel Cell -- H2 and O2 are combined to produce electricity and water in exactly the reverse reaction of electrolysis.
See the Related Questions to the left for more information.