This is Exercise 2.4.E. from Vakil's notes.
Show that a morphism of shaves of sets is an isomorphism if and only if it induces an isomorphism of all stalks.
My failed attempts:
I found some similar questions here and here. But I still couldn't figure out the details.
I have shown the "only if" part. I have also shown that if the morphism induces an isomorphism of stalks, it is injective.
The surjective part confused me a lot. Here is a commutative diagram:

To show surjectivity, suppose $g\in \mathscr{G}(U)$. Its image in the stalks at $p$ is $(g,U)_p$. Since $\phi_p$ is an isomorphism for all $p$, we have $(f_p,U_p)\in \mathscr{F}_p$, such that $\phi_p(f_p,U_p)=(g,U)_p$ for all $p\in U$. Now I don't know how to glue the $f_p$ together. Since even we have the pairs $(f_q,U_q)\in \mathscr{F}_q$, we cannot show that their restrictions on $U_p\cap U_q$ are equal. We have to find a small enough open set to glue them.
I also tried the open cover argument from the right hand side:
Since $\prod(g,U)_p$ consists of compatible germs, there exists an open cover $U_i$, and section $g_i$ in $\mathscr{G}(U_i)$, such that $(g,U)_p=(g_i,U_i)$ for all $p\in U_i$. But this doesn't help much. Since $\phi_p$ are different maps, we still cannot conclude anything about the $(f_p,U_p)$.
Any help will be greatly appreciated!