Moderately and heavily Mg-doped GaN were studied by a combination of post-growth annealing processes and electron beam irradiation techniques during cathodoluminescence (CL) to elucidate the chemical origin of the recombination centers responsible for the main optical emission lines. The shallow donor at 20-30 meV below the conduction band, which is involved in the donor-acceptor-pair (DAP) emission at 3.27 eV, was attributed to a hydrogen-related center, presumably a (V N -H) complex. Due to the small dissociation energy (<2 eV) of the (V N -H) complex, this emission line was strongly reduced by low-energy electron irradiation. CL investigations of the DAP at a similar energetic position in Si-doped (n-type) GaN indicated that this emission line is of different chemical origin than the 3.27 eV DAP in Mg-doped GaN. A slightly deeper DAP emission centered at 3.14 eV was observed following low-energy electron irradiation, indicating the appearance of an additional donor level with a binding energy of 100-200 meV, which was tentatively attributed to a V N -related center. The blue band (2.8-3.0 eV) in heavily Mg-doped GaN was found to consist of at least two different deep donor levels at 350±30 meV and 440±40 meV. The donor level at 350±30 meV was strongly affected by electron irradiation and attributed to a H-related defect.