  We consider the deformation theory of asymptotically conical (AC) and of
conically singular (CS) $G_2$-manifolds. In the AC case, we show that if the
rate of convergence $\nu$ to the cone at infinity is generic in a precise sense
and lies in the interval $(-4, 0)$, then the moduli space is smooth and we
compute its dimension in terms of topological and analytic data. For generic
rates $\nu < -4$ in the AC case, and for generic positive rates of convergence
to the cones at the singular points in the CS case, the deformation theory is
in general obstructed. We describe the obstruction spaces explicitly in terms
of the spectrum of the Laplacian on the link of the cones on the ends, and
compute the virtual dimension of the moduli space.
  We also present many applications of these results, including: the uniqueness
of the Bryant--Salamon AC $G_2$-manifolds via local rigidity and the
cohomogeneity one property of AC $G_2$-manifolds asymptotic to homogeneous
cones; the smoothness of the CS moduli space if the singularities are modeled
on particular $G_2$-cones; and the proof of existence of a "good gauge" needed
for desingularization of CS $G_2$-manifolds. Finally, we discuss some open
problems.
