Magnesium metal will react with hydrogen gas at very high pressures and at high temperatures to form magnesium hydride,
The balanced chemical equation that describes this synthesis reaction looks like this
#"Mg"_ ((s)) + "H"_ (2(g)) -> "MgH"_ (2(s))#
You can also think of this reaction as being an example of a redox reaction. Here magnesium metal is being oxidized by hydrogen gas which acts as a reducing agent.
Similarly, hydrogen is being reduced by magnesium which acts as an oxidizing agent.