none
Can I undo a Git Reset?

    Question

  • Using VS Community.  Apparently I clicked Reset accidentally while browsing my git history.  Then looking for an undo option, I even tried 'Amend previous commit'  for no good reason.  So now I'm way back at the original commit altho my project is still current (must've been the 'Keep' type of reset?).  I'm the only one working on this project so this was just to keep an ongoing record/backup but looks like it nearly had the opposite effect.  I'm fairly new to using git but I'd have thought there would be a confirmation if you're about to wipe out your whole project.  Is there any way to get my whole history back?
    Thursday, January 19, 2017 1:14 PM

Answers

  • Hi Beckler,

    I don't find a operate in Visual Studio to undo the reset operation. But as far as I know, we could undo the reset operation through Git command.

    Following thread introduce the detailed steps about the Git command to implement undo reset. Hope that can help you.

    http://stackoverflow.com/questions/2510276/undoing-git-reset

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Beckler Friday, January 20, 2017 3:58 AM
    Friday, January 20, 2017 3:02 AM
    Moderator

All replies

  • Hi Beckler,

    I don't find a operate in Visual Studio to undo the reset operation. But as far as I know, we could undo the reset operation through Git command.

    Following thread introduce the detailed steps about the Git command to implement undo reset. Hope that can help you.

    http://stackoverflow.com/questions/2510276/undoing-git-reset

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Beckler Friday, January 20, 2017 3:58 AM
    Friday, January 20, 2017 3:02 AM
    Moderator
  • Excellent, sir!  I installed the command prompt tools as described here:

    https://blogs.msdn.microsoft.com/visualstudioalm/2013/03/08/use-the-git-command-prompt-to-supplement-visual-studio/

    Then simply used the command to reset the head to the commit just before my accidental reset.  I'm now exactly back to where I was, my history is all restored and I feel much better. :D Thanks. 

    I think VS needs an undo feature here, and a confirmation on the Reset (maybe it has one on the Hard reset - I'm not going to try tho!)  As I just read on the git-scm site, Reset is one of the few 'dangerous' parts of git.  Altho I don't know git well, I would have never clicked Reset without knowing about it - it was a UI accident.

    Friday, January 20, 2017 3:58 AM