How to revert changes to just a block of code in Visual Studio using Git

Viewed 9192

I am used to VisualSVN (Visual Studio plug-in for SVN) feature to select a part of code and revert changes to it (by shortcut CTRL+ALT+Z) and not affect the changes in other parts of the same file.

Is there something similar for Git? Or I have to revert a whole file?

2 Answers

Some IDE such as Android Studio the shortcut CTRL+ALT+Z to revert on block of change is default function, you can use it since the IDE was installed.

But unfortunately, if you want to do the same thing in the VS Code, you should set this by yourself.

  1. File > Preferences > Keyboard Shortcuts. (Code > Preferences > Keyboard Shortcuts on macOS)
  2. Search "revert" as keywords
  3. "Git: Revert selected Ranged" will be found
  4. Allocate shortcut CTRL+ALT+Z to it
  5. Enjoy!
Related