Is there a command that allows you to partially undo the changes to a file (or files) in the working directory?
Suppose you have edited a file a lot but you realize that you want to undo some of the changes back to the committed state, but not the other changes.
I’m envisioning an option for git checkout that works a lot like git add -p, i.e. it goes through the file hunk by hunk and asks if you want to keep it or not.
You could use
to stage the chunks that you want to keep in a particular file, then
to discard the working tree changes that you didn’t want to keep, by checking out the staged version of the file.
Finally, you can use
to revert the staged version of the file to the most recent committed version of the file to leave you with your changes unstaged (if you don’t want to commit them).