Let $k$ be an algebraically closed field and $X, Y$ be quasiprojective $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$?

1$\begingroup$ I think that the answer is yes, essentially because $X$ is the fibered coproduct of $X_1,X_2$ along $X_1 \cap X_2$. In any case we can reduce to the case that $X$ is affine, then the corresponding diagram in the category of rings is a pullback diagram and its universal property gives the answer. $\endgroup$ – user45878 Mar 12 '18 at 22:24

$\begingroup$ Yes. Recall that a morphism between schemes is simply a morphism between the underlying locally ringed spaces, so no algebra is involved and no hypotheses are needed on $X$ and $Y$ other than they are locally ringed spaces. Just set $f$, as a map between locally ringed spaces, to be $f_1$ on $X_1$ and $f_2$ on $X_2$; this makes sense by the hypothesis that $f_1 \rvert_{X_1 \cap X_2} = f_2 \rvert_{X_1 \cap X_2}$. $\endgroup$ – Raymond Cheng Mar 13 '18 at 1:48

$\begingroup$ @RaymondCheng: that only works to define the map on topological spaces. You need to say what happens to the map of structure sheaves, so you need some relation between $\mathcal O_{X_1}$ and $\mathcal O_{X_2}$ on the one hand and $\mathcal O_{X_1 \cap X_2}$ on the other. $\endgroup$ – R. van Dobben de Bruyn Mar 13 '18 at 5:52

2$\begingroup$ @user45878: you have to be careful. Irreducible components are typically taken to have the reduced induced structure on them (this is the only canonical scheme structure on them, even if $X$ is nonreduced!). Therefore, $X = X_1 \amalg_{X_1 \cap X_2} X_2$ can only possibly be true if $X$ is reduced. Similarly, one has to specify what scheme structure is taken on $X_1 \cap X_2$, and if one takes the 'wrong' scheme structure it is easy to come up with counterexamples. $\endgroup$ – R. van Dobben de Bruyn Mar 13 '18 at 5:55
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 2527, 2002. Providence, RI: American Mathematical Society (AMS) (ISBN 0821834010/pbk). Contemporary Mathematics 386, 157172 (2005). ZBL1216.14003. Online version.