How to revert file in Visual Studio 2010 (reload the file from disc)
Asked Answered
C

3

13

I'm starting to use Visual Studio (2010) after years with Eclipse.

Every now and then I've found Eclipse's "Revert" feature pretty useful, that is, to reload the file from disk, discarding all changes. (Nothing to do with version control reverting.)

How can I do this with Visual Studio? Should be pretty simple but I haven't found it yet.

I know that I can do this with "undo until *-indicator disappears" but that's pretty impractical.

Cedeno answered 7/2, 2012 at 13:16 Comment(5)
Close it without saving it, and reloading it? There is no such built-in command though, so you need to do it manually. You can probably automate the undo command or the close/reload steps through the macro system though.Pre
This really is a version control system function. Commit frequently. You can setup a local repository.Gorlin
@RobSmyth : In many cases that helps pretty much but still every now and then I miss this. And most of text editors and IDEs I've used have this kind of revert functionality.Cedeno
Unfortunately, it is often VERY difficult to close the file. A single file may have several tabs open (e.g. Designer files); usually closing all of them works, but not always (e.g. Project properties). So far, the only sure way I've found is to exit Visual Studio! Surely there's a better way?Concord
Probably you need to install something like MZ-tools for that (pretty basic) functionalityQuestionless
E
5

Unfortunately I do not know of a built-in way to do this in VS other than closing the file and reopening it without saving.

There might be some extension that does this, but I am not aware of it :(

Elul answered 7/2, 2012 at 20:11 Comment(2)
The closed file usually shows up near the top of the File > Recent Files menu, which you can access with Alt+F, F, 1.Coats
Bálint's new answer is now the correct one. The option is available only in the "Open Editors" view.Sovereign
B
1

In the current version, you find in the Explorer, in the left sidebar. Then Open Editors, and right click on the file you want to revert.

Berrios answered 27/3, 2020 at 10:18 Comment(0)
O
0

If you are using git with Visual Studio: Solution Explorer > Right Click On File > Git > Undo Changes

Orang answered 14/10, 2021 at 14:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.