In his study of quantum groups, Drinfeld suggested considering set-theoretic solutions of the Yang–Baxter equation as a discrete analogon. As a typical example, every conjugacy class in a group or, more generally, every rack Q Q provides such a Yang–Baxter operator c Q : x ⊗ y ↦ y ⊗ x y c_Q \colon x \otimes y \mapsto y \otimes x^y . In this article we study deformations of c Q c_Q within the space of Yang–Baxter operators over some complete ring. Infinitesimally these deformations are classified by Yang–Baxter cohomology. We show that the Yang–Baxter cochain complex of c Q c_Q homotopy-retracts to a much smaller subcomplex, called quasi-diagonal. This greatly simplifies the deformation theory of c Q c_Q , including the modular case which had previously been left in suspense, by establishing that every deformation of c Q c_Q is gauge equivalent to a quasi-diagonal one. In a quasi-diagonal deformation only behaviourally equivalent elements of Q Q interact; if all elements of Q Q are behaviourally distinct, then the Yang–Baxter cohomology of c Q c_Q collapses to its diagonal part, which we identify with rack cohomology. This establishes a strong relationship between the classical deformation theory following Gerstenhaber and the more recent cohomology theory of racks, both of which have numerous applications in knot theory.