I want to edit an old commit in git. How do I undo just a part of an old commit?
(I am a bit of a git rookie, so sorry if I am confused about terms etc).

Example: in a commit, say three commits back, I deleted some code that should not have been deleted (yet). Now I want to go back and undo *that* particular change of that commit. It's a local repo.

What I have tried is what google gives me: stash + rebase -i + amend, but these invariably end up in a mess that takes (me) hours to resolve. None of them lets me actually edit the commit, only to do new changes - which in case of deleted code means me to locate and re-enter the deleted lines again, by hand (cut and paste). Then, even if the rebase is successful, the stash pop always fails... with a merge mess on my hands..). There just must be an easier way!

When I do a `git add -p`, it allows me edit the commit, line-by-line, and confirm what goes in. Now I want to redo that process, but on a commit. A `git unadd -p` of sorts, allowing me to delete the lines in the .patch with '-' in front.

Sorry, if my frustration with this comes through.