We describe discrete symmetries of two-dimensional Yang-Mills theory with gauge group G associated to outer automorphisms of G, and their corresponding defects. We show that the gauge theory partition function with defects can be computed as a path integral over the space of twisted G-bundles, and calculate it exactly. We argue that its weak-coupling limit computes the symplectic volume of the moduli space of flat twisted G-bundles on a surface. Using the defect network approach to generalised orbifolds, we gauge the discrete symmetry and construct the corresponding orbifold theory, which is again two-dimensional Yang-Mills theory but with gauge group given by an extension of G by outer automorphisms. With the help of the orbifold completion of the topological defect bicategory of two-dimensional Yang-Mills theory, we describe the reverse orbifold using a Wilson line defect for the discrete gauge symmetry. We present our results using two complementary approaches: in the lattice regularisation of the path integral, and in the functorial approach to area-dependent quantum field theories with defects via regularised Frobenius algebras.