I added individual steps for clarity. Note that g must be positive if the solution is to be real.
[tex]T=2\pi \sqrt{\frac{1}{g}}=2\pi g^{-\frac{1}{2}}\\g^{-\frac{1}{2}} = \frac{T}{2\pi}\\(g^{-\frac{1}{2}})^{-2} = (\frac{T}{2\pi})^{-2}\\g = \frac{4\pi^2}{T^2}\,\,\,, g>0}[/tex]
Let me know if you have any questions.