Reputation: 1758
Is there a way to revert to a previous git commit in VS code?
I know I can see the changes between commits and the differences in the working tree but I want to know how to reset to the previous commit in visual studio code.
Upvotes: 107
Views: 270162
Reputation: 1
Revert commit on local - discard changes and force push to remote: git push -f
Upvotes: 0
Reputation: 11655
I use GitLens for that:
File History
.Commit
.Revert Commit...
.Upvotes: 24
Reputation: 391
You can use this option in the Gitlens "commits" section to reset any number of previous (local) commits: just right click on the commit you would like to reset your current local branch
Then a list appears to allow you to choose a suitable reset option, as usual:
In recent vscode (1.51.1 currently installed) Gitlens extension has been integrated in the source control side view, by the way, instead of having its own button in the sidebar as before.
Upvotes: 12
Reputation: 182781
With the source control icon selected, if you then click the ellipsis ... at the top right.
With v1.48 you will see a list of options for submenus: under Commit
is Undo Last Commit
. Under Changes
is Discard All Changes
.
Upvotes: 139