how does one lift a morphism from a reduction?

Let $X$ be a scheme and let $f: X^\mathrm{red} \to Y$ be a morphism of schemes. Is it always possible to lift it to a morphism $f': X \to Y$ so that $f=f' \circ \mathrm{red}$ where $X^{red}$ is the reduction of $X$ and $\mathrm{red}: X^\mathrm{red} \to X$ is the natural closed embedding? Can one describe the set of such liftings, e.g. in terms of some cohomology group?

-

Suppose all schemes are $S$-schemes, for some scheme $S$.
Then you can always lift $f: X^\mathrm{red} \to Y$ to $f': X \to Y$ if $X$ is affine and $Y\to S$ is smooth.
The most important case is of course when $S=Spec(k)$ is the spectrum of a field.
Then for closed subschemes $Y\subset \mathbb A^n_k$ or $Y\subset\mathbb P^n_k$, smoothness can be checked through the Jacobian criterion, just like in advanced calculus!
Over perfect fields (for example algebraically closed fields or fields of characteristic $0$) smoothness coincides with non-singularity.

Edit:Bibliography
Hartshorne has written a fine set of lecture notes on deformation theory freely downloadable here. (The Springer GTM #257 book Deformation theory is exactly these notes plus some exercises.)
You will find a version of the lifting theorem for smooth schemes in Chapter 1, Section 4.

The most comprehensive treatment is EGA IV.4. §17, but as always cross-references make for more difficult reading.

-
How do you prove that for a smooth $Y$ you can always find a lifting? – Dima Sustretov Feb 17 '12 at 22:17
Dear Georges, thank you for the reference. – Dima Sustretov Feb 18 '12 at 9:42