Glue morphism of schemes defined over irreducible components Let $k$ be an algebraically closed field and $X, Y$ be quasi-projective $k$-scheme.
Let $X_1, X_2$ be two irreducible components of $X$ and $f_i:X_i \to Y$ be morphims such that $f_1|_{X_1 \cap X_2}=f_2|_{X_1 \cap X_2}$. Then, does the morphisms $f_1$ and $f_2$ glue to a morphism $f:X \to Y$ such that its restriction to $X_i$ is $f_i$?
 A: This is true in a suitable sense: if the closed subscheme $X_i$ is given by the ideal $\mathcal I_i$, then $X_1 \cap X_2$ is given by $\mathcal I_1 + \mathcal I_2$. In this case, it is true that
$$Y = X_1 \underset{X_1 \cap X_2}\amalg X_2,$$
where $Y \subseteq X$ is the closed subscheme given by $\mathcal I_1 \cap \mathcal I_2 \subseteq \mathcal O_X$. Your assumptions imply that $|Y| = |X|$, but the scheme structures may be different. However, everything is ok as long as $\mathcal I_1 \cap \mathcal I_2 = 0$. See for example [Sch05, Thm. 3.4, Thm. 3.5, Cor. 3.9].
Here is an example to show what can go wrong:
Example. Let $X = \operatorname{Spec} k[x,y]/(x^2y^2)$, and let $I_1 = (x)$ and $I_2 = (y)$. This is the naive thing to do, because $I_1$ and $I_2$ are the minimal primes of $X$. However, $I_1 \cap I_2 = (xy) \neq 0 \subseteq k[x,y]/(x^2y^2)$, showing that
$$X_1 \underset{X_1 \cap X_2}\amalg X_2 \cong \operatorname{Spec} k[x,y]/(xy).$$
The natural maps $X_1 \to X_1 \amalg_{X_1 \cap X_2} X_2 \leftarrow X_2$ agree on the point $X_1 \cap X_2 = \operatorname{Spec} k$, but they cannot come from a map $X \to X_1 \amalg_{X_1 \cap X_2} X_2$. Indeed, suppose $\phi \colon k[x,y]/(xy) \to k[x,y]/(x^2y^2)$ is a ring map whose compositions with $k[x,y]/(x^2y^2) \to k[x], k[y]$ are the projections. Then $\phi(x)$ is congruent to $x$ modulo $y$ and to $0$ modulo $x$. Therefore,
$$\phi(x)-x \in (x) \cap (y) = (xy) \subseteq k[x,y]/(x^2y^2),$$
and similarly for $\phi(y)-y$. If $\phi(x) = x + fxy$ and $\phi(y) = y + gxy$, we need
$$(x+fxy)(y+gxy) = 0 \in k[x,y]/(x^2y^2).$$
But the $xy$ term is visibly nonzero, so $\phi$ does not exist.

References.
[Sch05] Schwede, Karl, Gluing schemes and a scheme without closed points. In: Kachi, Yasuyuki (ed.) et al., Recent progress in arithmetic and algebraic geometry. Proceedings of the 31st annual Barrett lecture series conference, Knoxville, TN, USA, April 25--27, 2002. Providence, RI: American Mathematical Society (AMS) (ISBN 0-8218-3401-0/pbk). Contemporary Mathematics 386, 157-172 (2005). ZBL1216.14003. Online version.
