Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 217
broslav Avatar asked May 15 '17 10:05

broslav


1 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!
like image 163
Veja Avatar answered Nov 15 '22 02:11

Veja