Answer
$$\operatorname{proj}_{{g}} {f}
= 0.$$
Work Step by Step
Let $f(x)=x, \quad g(x)=\cos 2x$, $\langle f, g\rangle=\int_{-\pi}^{\pi}f(x)g(x) d x$
We have
$$\langle f, g\rangle=\int_{-\pi}^{\pi}x \cos 2x d x=\left[\frac{x}{2}\sin 2x+\frac{1}{4} \cos 2x\right]_{-\pi}^{\pi}=0,$$
$$\langle g, g\rangle=\int_{-\pi}^{\pi}\cos^2 2x d x=\frac{1}{2}\int_{-\pi}^{\pi}(1+\cos 4x) d x=\frac{1}{2}\left[x+\frac{1}{4}\sin 4x\right]_{-\pi}^{\pi}=\pi.$$
Now, the orthogonal projection of $f$ onto $g$ is given by
$$\operatorname{proj}_{{g}} {f}
=\frac{\langle{f}, {g}\rangle}{\langle{g}, {g}\rangle} {g}=0.$$