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.
Revert selected changes In the Changed Files pane, right-click the file that you want to revert and select Revert Selected Changes from the context menu. This results in a new commit that reverses the changes you want to undo.
With git version >= 1.7.1 I can
git checkout -p
I am not sure when this feature was introduced.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With