My physics textbook says when a rock is lifted gravity does negative work and increases the gravitational potential energy.
The problem with reading this statement in isolation is that it is ambiguous.
The first thing which is not clear is the system which is being considered.
Is it the rock alone or the rock & the Earth together?
The implication from the statement is that the system is the rock & the Earth as the rock by itself cannot have gravitational potential energy whereas the rock & the Earth can.
This is an important distinction because for the rock system the gravitational attraction on the rock due to the Earth is an external force whereas for the rock & Earth system the gravitational attraction on the rock due to the Earth is an internal force with its Newton third law pair being the gravitational attraction on the Earth due to the rock.
To simplify matters consider what happens to a rock with is moving upwards with some kinetic energy $K_{\rm start}$ and then some time later it has a kinetic energy $K_{\rm finish}$.
If the system is the rock alone then there is only one external force acting on the rock which is a downward force, the gravitational attraction on the rock due to the Earth $W$.
If the rock has moved up a distance $h$ then the work done on the rock by the gravitational force is $-W\,h$ with the minus sign being there because the displacement of the rock upwards is in the opposite direction to the downward external force on the rock.
So this is your "negative work done (on the rock system) by gravity".
Now using the work-energy theorem gives $-Wh = K_{\rm finish}- K_{\rm start}= \Delta K$ noting that the right-hand side of this equation will be negative.
Any other external force, eg your hand applying a force on the rock will contribute to the left-hand side (work done by an external force) of the equation so if you apply an upward force equal in magnitude to the weight of the rock then net work done will be zero and there will be no change in the kinetic energy of the rock.
If the system is the rock & the Earth then there are no external forces acting on the system but there will be the two equal magnitude and opposite direction gravitational forces acting on the rock and the Earth.
Often an assumption is made that the mass of the Earth $m_{\rm Earth}$ is much, much greater than that of the rock $m_{\rm rock}$ but in this case I want to make that assumption later in the analysis but I do want to make an assumption that if the initial upward velocity of the rock was $v_{\rm rock}$ then the initial "downward" velocity of the Earth was $\dfrac{m_{\rm rock}}{m_{\rm Earth}}v_{\rm rock}$ ie the initial momentum of the whole system was zero. If the rock starts from the Earth's surface and the radius of the Earth is $r_{\rm Earth}$ then the initial gravitational potential energy of the system is $-\dfrac{Gm_{\rm Earth}m_{\rm rock}}{r_{\rm Earth}}$ and the final potential energy is $-\dfrac{Gm_{\rm Earth}m_{\rm rock}}{r_{\rm Earth}+h}$.
So the change in the potential energy of the system is $-\dfrac{Gm_{\rm Earth}m_{\rm rock}}{r_{\rm Earth}+h} -\left (-\dfrac{Gm_{\rm Earth}m_{\rm rock}}{r_{\rm Earth}}\right )= \dfrac {Gm_{\rm Earth} m_{\rm rock}}{r_{\rm Earth}}\dfrac{h}{r_{\rm Earth}+h}$
Now we can make the approximation $r_{\rm Earth} \gg h$ to approximate the change in gravitational potential energy to $\dfrac {Gm_{\rm Earth} m_{\rm rock}}{r^2_{\rm Earth}}h = Wh$ where $W$ is the weight of the rock.
So in the end there is a decrease in the total kinetic energy of two components of the system and a corresponding increase in the the gravitational potential energy of the system $Wh$.
Although the internal forces acting on the Earth and the rock are of equal magnitude because the mass of the Earth is so much greater than that of the rock the internal force on the Earth will undergo a much smaller displacement than that of the rock so the work done by the internal force on the rock will be $-Wh$ the same as before.
This illustrates that the change in potential energy is equal to minus the work done by the conservative internal forces.