If you want to selectively discard a specific piece of your total diff, you can use the same -p option, but on the git checkout command. Be very sure about what you are doing when doing this, however, since it will discard the change completely as if you never wrote it.
It can be useful when you have a diff with many parts and you want to only discard a few of them but you don't want to have to select y for all of the ones you want when using git add -p.
If you want to selectively discard a specific piece of your total diff, you can use the same
-p
option, but on thegit checkout
command. Be very sure about what you are doing when doing this, however, since it will discard the change completely as if you never wrote it.It can be useful when you have a diff with many parts and you want to only discard a few of them but you don't want to have to select
y
for all of the ones you want when usinggit add -p
.That's really neat! Thanks for sharing this tip.
Would you mind if I quoted your comment on my original blog post (with attribution of course)?
Go ahead :)
Thanks, I've added it at the bottom of the original blog post: simonplend.com/how-to-review-your-...