How does hydrogen gas build up in hot water lines?
I think that it is probably due to a reaction between an acid and a metal. These reactions can lead to the formation of hydrogen following this generic forumula:
$$\ce{M + 2H+ -&gt; M^{2+} + H2}$$

For example iron could be a source of electrons. If you look at the corrosion of iron: $$\ce{Fe-&gt;Fe^{2+} + 2e^{-}}$$ 

At low pH (notice that there is a correlation between pH and temperature) hydrogen gas is formed:
$$\ce{2H^{+} +2e- -&gt; 2H2}$$