We have $$u(x, t) = g(x-at, 0) + \int_0^t f(x+a(s-t), s)ds$$ and want to show it satisfies the PDE $$\partial_t u + a \cdot Du = f$$
The solution given goes as follows $$\partial_t u + a\cdot Du = - a \cdot \nabla g(x-at) +f(x,t) + \int_0^t \nabla f(x+(s-t)a, s) \cdot (-a) ds \\ + a \cdot \nabla g(x-at) + a\cdot \int_0^t \nabla f(x+(s-t)a, s) ds$$ $$= f(x, t)$$ as required
However, I have no idea how these terms have appeared. In particular, I'm not sure why we have a grad appearing for $g$ and the $f(x, t)$ seems to come from nowhere...
Any insight is appreciated.
The first three terms arise from the chain rule to calculate $u_t$. First, you dot-multiply the gradient of $g$ by the derivative of the function inside $g$ with respect to $t$, which is the vector $-a$, next you have to take the $t$-derivative of an integral that contains $t$ both in the limit of integration and in the integrand. For that you have to combine the fundamental theorem, setting $s=t$ in the integrand, and a "convective" term including the $t$ derivative of the integrand $-a$. The last two terms arise in a similar way, but now to take the $x$ - gradient of the integral with fixed limits you just take it on the integrand.
It is just too long to write down all details...