I am really new to git and source control.
I am using visual studio tools for git with vs2012.
I am on some commit and want to go back to some previous commit but i cannot seem to do it how. When i go to the commit details the revert button seems to have been grayed out.
I have stuck on this problem for the last 2 hours. I have researched the internet but to no use. Please can somebody tell me how to revert to a previous commit.
Thanks.
The original commit is still in the Git history. To do the same in Visual Studio, right-click the commit you want to revert and then select Revert. After you confirm your action and the operation is complete, Visual Studio displays a success message and a new commit appears in the Outgoing section.
Steps to revert a Git commitLocate the ID of the commit to revert with the git log or reflog command. Issue the git revert command and provide the commit ID of interest. Supply a meaningful Git commit message to describe why the revert was needed.
In vscode press Ctrl + Shift + P , type git undo , and hit Enter .
Visual Studio 2015 Update 2 adds support for GIT "Reset", which is what you probably want to do:
You don't want to do a revert - revert just takes a commit and undoes it.
If you want to go back to a previous commit - there are two options:
If you want to permanently go back, do a git hard reset, which rolls back the code to a specified commit. You can do this via:
git reset --hard {commit number}
If you want to temporarily go back, you can create a branch from that commit. which will essentially keep you current path in the code history, and create another path from the point in history where that code was committed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With