M-theory compactified on $G_2$-holonomy manifolds results in 4d $mathcal{N}=1$ supersymmetric gauge theories coupled to gravity. In this paper we focus on the gauge sector of such compactifications by studying the Higgs bundle obtained from a partially twisted 7d super Yang-Mills theory on a supersymmetric three-cycle $M_3$. We derive the BPS equations and find the massless spectrum for both abelian and non-abelian gauge groups in 4d. The mathematical tool that allows us to determine the spectrum is Morse theory, and more generally Morse-Bott theory. The latter generalization allows us to make contact with twisted connected sum (TCS) $G_2$-manifolds, which form the largest class of examples of compact $G_2$-manifolds. M-theory on TCS $G_2$-manifolds is known to result in a non-chiral 4d spectrum. We determine the Higgs bundle for this class of $G_2$-manifolds and provide a prescription for how to engineer singular transitions to models that have chiral matter in 4d.