Let
$$\vec{f}(x_1,x_2) = g_1(x_1,x_2) \hat{i} + g_2(x_1,x_2) \hat{j} + g_3(x_1,x_2) \hat{k}$$
then using the definition of divergence we get,
$$\mathrm{div} f = \sum_{i = 1}^{2} \frac{\partial{g_i}}{\partial x_i}$$
what happens to $ \frac{\partial g_3}{\partial x_{what}}$, since I don't have third co-ord to take derivative with?
How is divergence defined for such cases if at all?
In your example, the divergence does not exist.
Divergence is a characteristic defined for functions of the form $\mathbf{F}:\mathbb{R}^3\rightarrow\mathbb{R^3}$. See the WA and Wiki articles.
The function in your example is of the form $\mathbf{G}:\mathbb{R}^2\rightarrow\mathbb{R}^3$. You cannot take $\text{div}\,\mathbf{G}$.