Using the first-principles exact muffin-tin orbital method combined with the coherent potential approximation, the crystal structure and site occupation, martensitic transformation, magnetic moment and elastic constant for each of Co2+xNi1-xGa, Co2+xNiGa1-x, Co2-xNi1+xGa and Co2Ni1+xGa1-x (0 & LE;x & LE; 0.4) alloys with Co and Ni excess at 0 K are systematically investigated. It is shown that most of the austenitic phases of the alloys have XA stable structure, and the excess Co and Ni atoms occupy the insufficient atomic positions, and it is inversely occupied only when Ni replaces Ga. With the increase of x, the total electron energy of L10 relative to XA of only two Ga-insufficient alloys gradually decreases, for the former, the tetragonal shear elastic constant gradually increases, but for the latter, it gradually decreases. It is indicated that the martensitic transformation is promoted by the substitution of both Co and Ni for Ga in the energy and mechanics, and the martensitic transformation temperature is expected to increase. The values of total magnetic moment (,/tot) of the XA phase and L10 phase of each alloy are mainly contributed by Co atoms, but onlya relatively small portion by Ni atoms. And the values of ,/tot of two phases in the four alloys have the same relationship with x, and the difference between them with the same compositions is not more than about 0.32 ,/B . The analyses of electronic structure calculations show that the distributions of spin-down electronic density of states of Co and Ni atoms near the Fermi energy level have contributed significantly to the stability of L10 relative to the XA phase, which is attributed to the Jahn-Teller effect. The above results are expected to provide a theoretical reference for the optimal design of the structure and properties of Co2NiGa-based ternary alloys.