Abstract The possible emergence of compact stars has been investigated in the recently introduced modified Gauss–Bonnet $$f(\mathcal {G},T)$$ f(G,T) gravity, where $$\mathcal {G}$$ G is the Gauss–Bonnet term and T is the trace of the energy-momentum tensor (Sharif and Ikram, Eur Phys J C 76:640, 2016). Specifically, for this modified $$f(\mathcal {G}, T)$$ f(G,T) theory, the analytic solutions of Krori and Barua have been applied to an anisotropic matter distribution. To determine the unknown constants appearing in the Krori and Barua metric, the well-known three models of the compact stars, namely 4U1820-30, Her X-I, and SAX J 1808.4-3658 have been used. The analysis of the physical behaviour of the compact stars has been presented and the...