Is there any way to "git reset –hard" in the VSCode app?

Issue

Is there any way to run git reset commands using the VSCode graphic interface? It seems like every other git operation is available. If not, then how can a GUI user resolve rewritten history on the remote?

If I pull a branch, and then someone else in the world runs git commit amend && git push --force to my branch so that the hash of the HEAD has changed, does VSCode’s git interface offer any way of resolving that? From a terminal I would normally just git fetch && git reset --hard origin/my-branch, but I work with people not comfortable on the command line. Is there any way to express to VSCode "abandon what I have without reservation and set my code to the latest remote"

image of vscode command palette search for "Git: reset"

Solution

If you install the GitLens extension, you can use that to perform a git reset:

enter image description here

After you select this command, it will display a list of commits to reset to, and then after choosing a commit, it will ask you how you want to reset (i.e. hard, soft, etc).

Gitlens also adds quite a lot more to the "git experience" for Visual Studio Code.

Answered By – Timothy G.

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published