microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.18k stars 29.29k forks source link

git reset --hard #164161

Open nweajoseph opened 2 years ago

nweajoseph commented 2 years ago

I would like to run git reset commands using the VSCode graphic interface. It seems like every other git operation is available. Without this, 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. It would be great to have a way for them to express to VSCode "abandon what I have without reservation and set my code to the latest remote"

vscodenpa commented 2 years ago

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

vscodenpa commented 1 year ago

This feature request has not yet received the 20 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

Sbrjt commented 5 months ago

For now, you can create your own task.

Go to task.json, add the following task (rollback) and an input variable:

{
   "tasks": [
         ......
         // add this in the tasks
    {
        "label": "Rollback",
        "type": "shell",
        "command": "git reset --hard ${input:commitHash} ; git push --force"
    }
   ],
   "inputs": [
    {
        "id": "commitHash",
        "type": "promptString",
        "description": "Enter the commit hash to rollback to"
    }
   ]
}

Note: If you want to preserve the history and see a rollback msg, you may instead try: "command": git diff HEAD ${input:commitHash} | git apply ; git add . ; git commit -m 'Rollback to ${input:commitHash}' ; git push