When can stalks be glued to recover a sheaf?
First of all:
Let $X=Spec A$ be an affine integral scheme with structure sheaf $\mathcal{O}_X$.
We have: $$ \mathcal{O}_{X,x}= \underset{{x\in X_f}}{ \underrightarrow{\lim}} \mathcal{O}_X(X_f)=\underset{{f \notin \mathfrak{p}_x}}{\underrightarrow{\lim}} A_f = \bigcup_{f \notin \mathfrak{p}_x} A_f $$ But we also have (I hope): $$ \mathcal{O}_X(X_f)=A_f=\bigcap_{f\notin\mathfrak{p}_x\subset A} A_{\mathfrak{p}_x}=\underset{{f \notin \mathfrak{p}_x}}{\underleftarrow{\lim}} A_{\mathfrak{p}_x}=\underset{{x \in X_f}}{\underleftarrow{\lim}} \mathcal{O}_{X,x} $$
The first equality is false, because for any commutative ring $A$ with unit: \begin{equation} \forall\mathfrak{p}\in\operatorname{Spec}A,\,\lim_{\overrightarrow{f\notin\mathfrak{p}}}A_f=A_{\mathfrak{p}} \end{equation} and the second equality is partially true, that is: \begin{equation} \mathcal{O}_X(D(f))=A_f=\bigcap_{\stackrel{\mathfrak{p}\in\operatorname{Spec}A}{f\notin\mathfrak{p}}}A_{\mathfrak{p}} \end{equation} where I prefer the notation $D(f)$ for the open set \begin{equation} \{x\in\operatorname{Spec}A\mid f(x)\neq0\}. \end{equation} At most in general, the following lemma holds.
Lemma. Let $(X,\mathcal{T})$ be a topological space with topology $\mathcal{T}$ and $\mathfrak{B}$ a basis for $\mathcal{T}$; that is a system of open subsets of $X$ such that:
- $U,V\in\mathfrak{B}\Rightarrow U\cap V\in\mathfrak{B}$,
- every open subset of $X$ is a union of sets from $\mathfrak{B}$.
We can view $\mathfrak{B}$ as a category with objets its elements and the inclusions between the sets as morphisms.
Let $\mathcal{O}:\mathfrak{B}\to\mathbf{C}$ be a controvariant functor (or $\mathfrak{B}$-presheaf), where $\mathbf{C}$ is a category closed with respect to projective limits, such that $\mathcal{O}$ satisfies the sheaf conditions for coverings of type $\displaystyle U=\bigcup_{i\in I}U_i$, where $\forall i\in I,\,U,U_i\in\mathfrak{B}$.
Then $\mathcal{O}$ can be extended to a sheaf $\overline{\mathcal{O}}$ on $X$, where: \begin{equation} \forall U\in\mathcal{T},\,\overline{\mathcal{O}}(U)=\lim_{\overleftarrow{V\in\mathfrak{B}\,\text{with}\,V\subseteq U}}\mathcal{O}(V) \end{equation} and this extension is unique up to canonical isomorphism.
For a proof one can consult Bosch S. - Algebraic Geometry and Commutative Algebra, chapter 6, section 6, lemma 4.
Let $(X,\mathcal{T})$ be a topological space and let $\mathcal{F}$ be a sheaf on $X$ with values in a category $\mathbf{C}$ closed with respect to inductive and projective limits.
Let $x,y\in X$ such that $x\in\overline{\{y\}}$, or in other words: \begin{equation} \forall U\in\mathcal{T},\,x\in U\Rightarrow y\in U; \end{equation} then the following diagrams commute: \begin{equation} \require{AMScd} \forall V\subseteq U\in\mathcal{T},x,y\in V,x\in\overline{\{y\}},\, \begin{CD} \mathcal{F}(U) @>r_{U,x}>> \mathcal{F}_x\\ @V{r^U_V}VV @VV{=}V\\ \mathcal{F}(V) @>>\dot\exists r_{V,x}> \mathcal{F}_x \end{CD}, \begin{CD} \mathcal{F}(U) @>r_{U,y}>> \mathcal{F}_y\\ @V{r^U_V}VV @VV{=}V\\ \mathcal{F}(V) @>>\dot\exists r_{V,y}> \mathcal{F}_y \end{CD},\dot\exists r_{y,x}:\mathcal{F}_x\to\mathcal{F}_y \end{equation} and therefore $(\mathcal{F}_x,r_{y,x})_{x,y\in X}$ is a projective system in $\mathbf{C}$; where I get: \begin{gather} x\succcurlyeq y\iff x\in\overline{\{y\}}\,\text{or}\,x=y;\\ \forall U\in\mathcal{T},\,\mathcal{G}(U)=\lim_{\overleftarrow{x\in U}}\mathcal{F}_x. \end{gather} Let $\mathfrak{B}$ be a basis of $(X,\mathcal{T})$, let $V\subseteq U\in\mathfrak{B}$, let $x,y\in V$ such that $y\in\overline{\{x\}}\iff x\prec y$; then one can consider the diagram \begin{equation} \mathcal{G}(U)\stackrel{\displaystyle\left(r_y^U\right)^{\prime}}{\longrightarrow}\mathcal{F}_y\stackrel{\displaystyle r_{x,y}}{\longrightarrow}\mathcal{F}_x\stackrel{\displaystyle\left(r_x^V\right)^{\prime}}{\longleftarrow}\mathcal{G}(V) \end{equation} by the universal property of $\mathcal{G}(V)$: \begin{equation} \dot\exists r^U_V:\mathcal{G}(U)\to\mathcal{G}(V)\mid\left(r_x^V\right)^{\prime}\circ r^U_V=r_{x,y}\circ\left(r_y^U\right)^{\prime}, \end{equation} by definition $\mathcal{G}$ is a $\mathfrak{B}$-presheaf.
The $\mathfrak{B}$-sheaf axioms for $\mathcal{G}$ are equivalent to affirm that for any $U\in\mathfrak{B}$ and for any (open) covering $\{U_i\in\mathfrak{B}\}_{i\in I}$, $\mathcal{G}(U)$ is the equilizer of the diagram \begin{equation} \prod_{i\in I}\mathcal{G}(U_i)\rightrightarrows\prod_{i,j\in I}\mathcal{G}(U_{ij}) \end{equation} where I get $U_{ij}=U_i\cap U_j$ and the double arrows is the categorical product (in $\mathbf{C}$) of the morphism $r^{U_i}_{U_{ij}}$ and $r^{U_j}_{U_{ij}}$.
By definition of $\mathcal{G}$: $\mathcal{G}(U)$ equalizes the previous diagram; let $E$ be the equalizer of the previous diagram, then: \begin{equation} \forall i,j\in I,x_i\in U_i,y_{ij}\in U_{ij},\dot\exists\varphi_i:E\to\mathcal{F}_{x_i},\varphi_{ij}:E\to\mathcal{F}_{y_{ij}} \end{equation} such that the $\varphi_i$'s and $\varphi_{ij}$'s commute opportunely with the $r_{x_{ij},x_i}$'s; by definition $(E,\varphi_{ij})_{i,j\in I}$ is a cone (in $\mathbf{C}$) on the projective system $(\mathcal{F}_x,r_{y,x})_{x,y\in U}$, by the universal properties of $\mathcal{G}(U)$ and $E$: they are canonically isomorphic, that is $\mathcal{G}$ is a $\mathfrak{B}$-sheaf; by previous lemma $\mathcal{G}$ is extendible to a sheaf on $X$.
Whithout confusion, I can continue to write $\mathcal{G}$ for both sheaves!
For any $U\in\mathcal{T}$, by previous reasoning, one can consider $\mathcal{F}(U)$ as a cone over the projective system $(\mathcal{F}_x,r_{y,x})_{x,y\in U}$; then by universal property of $\mathcal{G}(U)$, there exists a unique morphism $\varphi_U:\mathcal{F}(U)\to\mathcal{G}(U)$ such that it (opportunely) commutes whit the $r_{y,x}$'s; in particular, the data of $\varphi_U$'s defines a morphism $\varphi:\mathcal{F}\to\mathcal{G}$ of sheaves. In this way, one can define the canonical morphism $\varphi_x:\mathcal{F}_x\to\mathcal{G}_x$, for any $x\in X$.
For any $x\in X$, $\left(\mathcal{F}_x,\left(r^U_x\right)^{\prime}\right)_{x\in U}$ and $\left(\mathcal{G}_x,r^U_x\right)_{x\in U}$ are cocones for the inductive system $\left(\mathcal{G}(U),r^U_V\right)_{x\in U,V}$; by the couniversal property of $\mathcal{G}_x$, there exists a unique morphism $\psi_x:\mathcal{G}_x\to\mathcal{F}_x$; in particular, the data of $\psi_x$'s defines a morphism $\psi:\mathcal{G}\to\mathcal{F}$ of sheaves.
Using the couniversal property of the stalks of a sheaf, one can prove that: \begin{equation} \forall x\in X,\,\psi_x\circ\varphi_x=Id_{\mathcal{F}_x},\varphi_x\circ\psi_x=Id_{\mathcal{G}_x}; \end{equation} in other words, $\mathcal{F}$ and $\mathcal{G}$ are canonical isomorphic sheaves on $X$ with values in $\mathbf{C}$. $\Box\,(Q.E.D.)$