Revert a single file to earlier commit using Git Extensions for Visual Studio Revert a single file to earlier commit using Git Extensions for Visual Studio git git

Revert a single file to earlier commit using Git Extensions for Visual Studio


The easiest way to do this in Git Extensions is to open the file history (e.g., from the context menu in Visual Studio) for the file you want to revert. Then find the revision you need and choose "Save As" in the context menu.

To revert changes made to a file in the working directory, just choose "revert changes" from the context menu in Visual Studio.


While the technique suggested by @Henk will work, here's the Git way.

  1. Select the commit that changed the file you wish to revert.
  2. Choose the revert commit operation. Be sure you tell Git Extension not to automatically commit the revert operation. This will result in a) A revert operation on the affected file(s) and b) Reverted file(s) being staged

Then you can unstage the file(s) that you do not wish reverted -- leaving only the one file that you do wish to revert to be committed.

While this might seem more tedious that just File > Save As, it comes in handy when you have to revert a handful of files.


Edited my post. I don't know why I responded about mercurial. Sorry about that. The same idea goes for git. I used tortiseGit (when I used git), but the command line is easier. TortiseGit is still a right click to revert. The command line is just 'git checkout filename' to get the checkout from the HEAD.