Using the cocycle condition to glue sheaves Given a cover $\{U_i\}$ of a space $X$ and for each $U_i$ a sheaf $\mathcal{F}_i$ and isomorphisms $\phi_{ij}:\mathcal{F_j}|_{U_i \cap U_j} \rightarrow \mathcal{F_i}|_{U_i \cap U_j}$ satisfying the cocycle condition $\phi_{ij}\phi_{jk}\phi_{ki} = id$, I want to show that there is a sheaf $\mathcal{F}$ on $X$ whose restriction to each $U_i$ is isomorphic to $\mathcal{F_i}$. I understand that $\mathcal{F}(U)$ should consist of tuples $(s_i)$ of sections from the various sheaves, then I need to define restriction maps, prove the presheaf axioms and then the sheaf axioms. I have at least a vague idea of how the proof should go. Unfortunately, on my way to proving the result I get utterly lost in an unholy mess of details, so that even once I "finished" my proof I was nowhere near certain my proof was correct. I've searched around for proofs to examine, but any proof I can find is either lacking many details or required as an exercise.
Here are my questions:
1) Can someone show me a proof of this result? I am interested to see both a direct proof checking all the details and also a more intuitive proof, possibly appealing to results about gluing morphisms or whatnot.
2) Should the tuples $(s_i)$ be leaving in the product or the disjoint union of the $\mathcal{F_i}(U\cap U_i)$? I thought it would be product, but I saw union on Google Books in Introduction to Singularities and Deformations by Greuel, Lossen, and Shustin.
3) Where does the cocycle condition come into play?
4) How can I prevent all these messy sheaves from deterring me from the beautiful subject of algebraic geometry?
Thanks in advance.
 A: You should really be able to do this directly. The calculations are not messy at all, in my opinion. Also, they are straight forward. It is also a good idea to simplify the notation and to use words more than formulas. This way you really understand what is going on.
You define $F(U)$ to be the set of all families $s=(s_i)$ of sections $s_i \in F_i(U \cap U_i)$ which are compatible in the sense that $\phi_{ij}(s_j)=s_i$ for all $i,j$. I have simplified the notation here: Of course we restrict $s_i$ and $s_j$ to $U \cap U_i \cap U_j$, and of course we apply $\phi_{ij}$ at this open subset.
The restriction maps of $F$ are induced by the ones for $F_i$. They are well-defined because the asserted compatibility is preserved by restriction, which in turn works since $\phi_{ij}$ commutes with restriction maps. After having checked this, it is obvious that $F$ becomes a presheaf, using the presheaf properties of the $F_i$.
Now as for the first sheaf condition, let $s=(s_i)$ be as above, and $U = \cup_p W_p$ be an open cover. If $s$ is trivial on each $W_p$, this means that $s_i \in F_i(U \cap U_i)$ is trivial on each $W_p \cap U_i$. But since these cover $U \cap U_i$, it follows $s_i=0$, for all $i$, hence $s=0$. (For sheaves of sets, you can adjust this argument easily.)
For the second sheaf condition, let $s^p \in F(W_p)$ be a family of compatible sections (compatiblity means that $s^p$ and $s^q$ agree on $W_p \cap W_q$). This means that for every $i$ we have a family of compatible sections $s^p_i \in F_i(W_p \cap U_i)$ with respect to the cover $\{W_p \cap U_i\}$ of $W \cap U_i$. Since $F_i$ is a sheaf, these glue to a section $s_i \in F_i(W \cap U_i)$. We have $\phi_{ij}(s_j)=s_i$ in $F_i(U \cap U_i \cap U_j)$, since this is true when restricted to each $W_p \cap U_i \cap U_j$, since $s^p \in F(W_p)$. Hence, $s:=(s_i) \in F(U)$ and $s$ restricts to $s^p$ on $W_p$ by construction.
Thus, $F$ is a sheaf.
The cocycle condition is not needed to make this construction work. We don't even need that the $\phi_{ij}$ are isomorphisms! This is especially clear in the category-theoretic construction of $F$, see for example Zhen Lin's answer here.
But there is a reason why one usually demands this condition: We would like to have that the projection $F|_{U_i} \to F_i$ mapping a section $s$ to $s_i$ is an isomorphism. We simply construct an inverse by mapping $s_i$ to $s$ defined by $s_j = \phi_{ij}^{-1}(s_i)$ (here we need that $\phi_{ij}$ is an isomorphism). This is consistent when $\phi_{ii}=\mathrm{id}$ (which would follow from the cocycle condition). By construction $\phi_{ij}(s_j)=s_i$, but in order to be a section of $F$, we also need $\phi_{kj}(s_j)=s_k$ for all $k$, i.e. $\phi_{kj} = \phi_{ki} \circ  \phi_{ij}$, which is precisely the cocycle condition. One then checks that this describes a map $F_i \to F|_{U_i}$ which is inverse to the projection.
There is even an a priori motivation for the cocycle condition. Given a gluing datum of sheaves $(F_i,\phi_{ij})$, we want to find a sheaf $F$ with isomorphisms $F|_{U_i} \cong F_i$, but in such a way that the induced isomorphisms $F_j|_{U_i \cap U_j} \cong F|_{U_i \cap U_j} \cong F_i|_{U_i \cap U_j}$ really equal $\phi_{ij}$. But these isomorphisms obviously satisfy the cocycle condition: If we compose (let me again simplify the notation) $F_k \to F \to F_j$ with $F_j \to F \to F_i$, then $F \to F_j \to F$ cancels to the identity, so that we get $F_k \to F \to F_i$. In other words, in the following diagram, the outer triangle commutes because all three inner triangles commute:

