Metal + Acid = Salt + hydrogen (gas)
Magnesium+ hydrochloric acid = Magnesium chloride + hydrogen (gas)
The electronic configuration of Mg - 2,8,2
i.e number of the valence electron is 2.
There is covalent bond between hydrogen and chlorine.
The electronic configuration of Cl- 2,8,7
`Mg+2HCl->Mg^(++)Cl^- _2+H_2 uarr`
In formation of magnesium chloride , magnesium loses 2 electrons and chlorine gains two electrons. After losing electron magnesium become magnesium ion and after gaining electrons chlorine become chloride ion. So an ionic bonds form between Mg and Cl_2. Covalent bond between H_2 and Cl_2 break , Thus Hydrogen gas released.