I always confuses on the definition, and wiki did not have any summary. so,

The Original definition is the Hamiltonian of a magnetic dipole under external magnetic field $\vec{B}$,

$H = -\vec{\mu}\cdot \vec{B}$,

where $\vec{\mu}$ is magnetic dipole moment (MDM). It is

$\vec{\mu} = g \frac{q}{2 m} \vec{J} = g \frac{\mu}{\hbar} \vec{J} = \gamma \vec{J}$.

Here, the $g$ is the g-factor, $\mu$ is magneton, and $\vec{J}$ is the total spin, which has a intrinsic factor $m\hbar / 2$ inside. $\gamma$ is gyromegnetic ratio.

We can see, the g-factor depends on the motion or geometry of the MDM. For a point particle, the g-factor is exactly equal to 2. For a charged particle orbiting, the g-factor is 1.

Put everything into the Hamiltonian,

$H = -\gamma \vec{J}\cdot \vec{B} = -\gamma J_z B = -\gamma \hbar \frac{m}{2} B [J]$,

Because energy is also equal $E = \hbar f$, thus, we can see the $\gamma$ has unit of frequency over Tesla.

———————————–

Take electron as an example, the MDM is Bohr magneton $\mu_{e} = e\hbar/(2m_e)$. The MDM is,

$\vec{\mu_e} = g_e \frac{e}{2 m_e} \vec{S} = g_e \frac{\mu_e}{\hbar}\vec{S} = \gamma_e \vec{S}$.

The magnitude of MDM is,

$|\vec{\mu_e}|= g_e \frac{e}{2 m_e} \frac{\hbar}{2} = \gamma_e \frac{\hbar}{2} [JT^{-1}]$,

The gyromagnetic ratio is,

$\gamma_e = g_e \frac{\mu_e}{\hbar} [rad s^{-1} T^{-1}]$.

Since using $rad s^{-1}$ is not convenient for experiment. The gyromagnetic ratio usually divided by $2\pi$,

$\gamma_e = g_e \frac{\mu_e}{2\pi\hbar} [Hz T^{-1}]$.

————————————-

To evaluate the magnitude of  MDM of  single particle state, which has orbital angular momentum and spin, the total spin $\vec{J} = \vec{L} + \vec{S}$. However, the g-factor for $\vec{L}$ is difference from that for $\vec{S}$. Thus, the MDM is not parallel to total spin. We have to use Landé Formula,

$\left< JM|\vec{V}|JM'\right> = \frac{1}{J(J+1)} \left< JM|(\vec{J}\cdot\vec{V})|JM\right> \left$

or see wiki, sorry for my laziness.

The result is

$g=g_L\frac{J(J+1)+L(L+1)-S(S+1)}{2J(J+1)}+g_S\frac{J(J+1)-L(L+1)+S(S+1)}{2J(J+1)}$

For $J = L \pm 1/2$,

$g = J(g_L \pm \frac{g_S-g_L}{2L+1})$