rahul  Kushwaha
rahul Kushwaha

Reputation: 2809

How to roll back previous history of the file git vscode?

How to reload the previous history of the file in git source control in vscode? vs code provides to restore only last commit and I can see all the history of the file with "Git History" extension in vscode but is there any way to roll back to any history of the file?

Upvotes: 5

Views: 15436

Answers (2)

Cassio Seffrin
Cassio Seffrin

Reputation: 8560

There is an awesome extension called GitLens for that:

After installed, go to thee source control tab, right click on the file and select, "Open File History". Select your commit, then right click over it and click "Restore" from popup menu.

enter image description here

Upvotes: 11

emremrah
emremrah

Reputation: 1765

If you want to checkout a previous commit, I recommend to do it using command line:

  • hit ctrl + j to open up a terminal in VSCode
  • type git log to see commit history (or you can do that by looking the commit history from repo's page, e.g on Github). the commits are sorted that the upper one is more recent
  • Copy the long SHA key of the commit you want to checkout and run git checkout sha_key. sha_key is the key you just copied

Upvotes: 4

Related Questions