Reputation: 615
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?
Upvotes: 13
Views: 15371
Reputation: 615
In Visual Studio 2022 there are improved Git controls, so while looking at current file diff one can now select a range (e.g. select lines that include one or more changes) and revert them all at once using context menu item Git -> Revert Selected Range.
By default, there is no shortcut, but you can configure a specific keyboard shortcut for that menu item in "Tools -> Options -> Keyboard" settings.
Note: This is currently available only while in diff window, not in the general text editor.
Upvotes: 1
Reputation: 121
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.
Upvotes: 8
Reputation: 41
I know this question is a little old, but this is what worked for me in Visual Studio Code (not sure if this would work in Visual Studio as they are separate applications):
The code block should be reverted. Hopefully this helps someone even if it doesn't answer the actual question.
Upvotes: 0