Another possibility is using the Git Staging view:
- Open Git Staging view by pressing Ctrl+3 or Command+3 and typing
staging
- In case the view does not already show your repository, click on the project or file
- You should now see the files you modified in the Unstaged Changes section
- Double-click on the unstaged file
- You now see a compare view with your version on the left and the version before the changes on the right
Now, to undo only some of the changes in the file, do the following:
- In the compare view, select one of your changed lines
- Select the Copy Current Change From Right to Left toolbar item
This will make the left side correspond to the right side for this change. Save the file to finish the undo.
To undo all of your changes:
- In the staging view, right click on the unstaged file
- Select Replace With File in Git Index
You can also select more than one unstaged file and then right click.