15

I have a commit done by a developer in the remote Git repository hosted in VSTS that needs to be rolled back. From Visual Studio, without going to the command prompt or how to revert the commit?

I want to undo the commit through Visual Studio without using a command prompt.

5
  • It would be better to apply a new commit that restored the repository to a previous state instead of retroactively rewriting history by "deleting" the last commit.
    – Dai
    Aug 23, 2017 at 19:31
  • 1
    Possible duplicate of How to revert Git repository to a previous commit?
    – Dai
    Aug 23, 2017 at 19:31
  • 1
    Also, why are you opposed to using the git command-line? It's the best way to become familiar with how git works - the GUI built-in to Visual Studio hides many important details that I personally feel are necessary for the inexperienced to be exposed to.
    – Dai
    Aug 23, 2017 at 19:32
  • 1
    Please read the entire question before voting as dublicated. I want to undo the commit through Visual Studio without using a command prompt. @Dai Aug 23, 2017 at 21:31
  • I already know how to do it from the command prompt, but I need to know how to do it inside Visual Studio. Aug 23, 2017 at 21:35

2 Answers 2

22

Selected answer is not correct. In order to undo a commit you need to select reset, not revert. Revvert will make a new commit with code contained in previous commit. Where reset will actually delete the commits after the selected version.

6
  • 1
    The question literally asks how to revert from the UI. It doesn’t ask how to “undo”, which itself would require explanation. Jul 20, 2019 at 8:20
  • 6
    The question also literally asks how to undo. in fact it says the word undo twice. I believe the OP was just using a synonym for undo when he says revert, and in fact does not mean specifically a git revert command.
    – AllenKll
    Jul 21, 2019 at 15:30
  • 1
    And it uses the word revert once, and again in a comment that explicitly mentions the command line. Your answer that explains the difference between revert and reset is useful, but your assumption that the OP wants to do a reset doesn't have much basis. Regardless, as it stands, this is a comment on an existing answer, not an answer to the question itself. Showing how to both reset and revert in Visual Studio would make this a very good answer to the question. Jul 21, 2019 at 15:46
  • 3
    Regarding the difference between revert and reset, this answer is clearer than the one in MS documentation.
    – jcs
    Sep 27, 2019 at 18:11
  • 3
    I wish your answer was the selected answer, now I've got an extra commit to somehow get rid of.... May 13, 2020 at 15:33
12

Open the "Changes" tab in Team Explorer. Select "Actions", then "View History" to view the history of the repository. Identify the commit that you want to revert, right-click on it and select "Revert" from the context menu.

Revert

5
  • 1
    FWIW, gitforvisualstudio.com is some lovely training for Git in Visual Studio. (I must admit that I'm biased, though.) Aug 23, 2017 at 21:43
  • Thanks for that link, that will certainly come in handy for coworkers in the future! ;)
    – poke
    Aug 23, 2017 at 21:57
  • @EdwardThomson y'know what would be nice? If the context-menus for git operations had a tooltip that showed you the command-line equivalent of that menu option. So "Revert" would say "git revert {commit}`, for example.
    – Dai
    Aug 23, 2017 at 22:52
  • Thanks for the feedback @Dai, I'll bring your suggestion to the team that works on the VS integration. Aug 23, 2017 at 23:00
  • This doesn't work. This makes a new commit that indicates that a commit was reverted. this is not the same as undo-ing a commit.
    – AllenKll
    Jul 20, 2019 at 4:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.