The following result is a direct consequence of Proposition 27.1 of F. W. Anderson and K .R. Fuller's "Rings and categories of modules". But I cannot prove it. Is there any hint?
Definition: Let $A$ be an ideal in a ring $R$ and let $g+A$ be an idempotent element of $R/A$. We say that this idempotent can be lifted modulo $A$ in case there is an idempotent $e^2=e\in R$ such that $g + A = e + A$.
Fact: Let $I$ be an ideal of a commutative ring with identity. Then every idempotent of $R/I$ can be lifted modulo $I$ if and only if every idempotent of $R/\sqrt{I}$ can be lifted modulo $\sqrt{I}$, where $\sqrt{I}$ is the radical of $I$ in $R$.
$(\Rightarrow)$ An idempotent in $R/\sqrt{I} \cong (R/I)/(\sqrt{I}/I)$ lifts to an idempotent of $R/I$ by the proposition, since $\sqrt{I}/I$ is a nil ideal in $R/I$. In turn this lifts to an idempotent of $R$ by assumption.
$(\Leftarrow)$ If $g+I \in R/I$ is idempotent, then since $I \subseteq \sqrt{I}$, by assumption there is an idempotent $e \in R$ with $e-g \in \sqrt{I}$. Then the following fact applied to $R/I$ shows that $e - g \in I$ as desired.
Proof: Compute $(e - e')^3 = e - e'$, so $(e - e')^{2n+1} = e - e'$ by induction, and the left side is zero for large enough $n$.
The above fact strengthens the proposition: If $I$ is a nil ideal in $R$, then idempotents in $R/I$ lift uniquely to idempotents in $R$.