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

I've found instructions on how to revert a single file in a Git repository to an earlier version. But I am curious if anyone knows of a way to do this using Git Extensions for Visual Studio. This tool works great so far and I really like it, but I can't figure out how to do this one thing.

Answers


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.


Need Your Help

Time complexity of node deletion in singly- and doubly-linked lists

linked-list complexity-theory time-complexity singly-linked-list doubly-linked-list

Why is the time complexity of node deletion in doubly linked lists (O(1)) faster than node deletion in singly linked lists (O(n))?

jQuery not working in AJAX Loaded page

php javascript jquery ajax click

I am using jQuery to load a page by AJAX using $.ajax (suppose test.html).Its a simple HTML document with a few buttons and associated animations upon clicking them (also using jQuery).The .click()