Vscode: Undo last commit greyed out

Created on 4 Oct 2016  路  14Comments  路  Source: microsoft/vscode

  • VSCode Version: Code - Insiders 1.6.0-insider (17b0c8d028d3b7ceaf3b7c2c226cd0ad6b1feb51, 2016-09-30T06:10:50.521Z)
  • OS Version: Windows_NT ia32 10.0.14393
  • Extensions: dbaeumer.vscode-eslint-1.0.7, donjayamanne.githistory-0.0.12, ms-vscode.csharp-1.4.1, ms-vscode.PowerShell-0.7.2, ow.vscode-subword-navigation-1.1.5, rebornix.Ruby-0.8.0, WallabyJs.wallaby-vscode-1.0.27

Steps to Reproduce:

  1. Open a repo with existing commits
  2. Try to undo the last commit
  3. The button is greyed out
bug git verified

Most helpful comment

Doesn't it seem a little silly to tell people that the way to enable the "undo last commit" action is to commit other stuff that they don't want committed? At which point the "undo last commit" action would undo that commit, and you still wouldn't be able to undo the one you originally intended to undo?

I understand the caution around merging, but I think maybe we've lost sight of the 90% use case here: I just hit commit by mistake, and I want to undo it. There are no intervening changes, so no merge issue; I just want to undo the commit I did 3 seconds ago. Why must that be impossible (within the editor) just because I have other, unrelated changes? I'd like to dispute the assertion that "most will be annoyed" with supporting the likeliest use case.

All 14 comments

The Undo last commit action stays disabled while you have changes in your repository. Either commit or clean those changes before running that action.

@joaomoreno It used to work until a few days ago (Insider build) and I used to use it so that I can easily amend my last commit. I don't think there's any reason to grey it out, it was very useful.

One of the reasons I loved it is because it would put the previous commit message in the commit message box so that I can add any more information to it reflecting the additional changes I have made.

The action is still there.

Can you show me a screenshot of VS Code at the moment the action is disabled?

Sorry I read my last post and it wasn't very clear.

The button is only greyed out when there are changes (as you said). However, this behaviour is new. It never used to be greyed out when there were changes. I was saying I preferred the old behaviour.

It's not wise to undo your last commit when your working tree is still dirty, because you will merge the changes from the last commit with your current changes. Some people like that, but most will be annoyed by that behaviour, so we went with the current option.

Some people like that, but most will be annoyed by that behaviour, so we went with the current option.

Let me voice my +1 for one of the people that liked the old behaviour.

GitHub Desktop has the same behaviour, and I used it all the time there as well.

Workaround: git stash -u, then undo, then git stash pop.

Or just run git reset HEAD~.

That's what the undo last commit command does.

@dominic31 Thanks for the comment. The value in this behaviour was that it would populate your last commit message in the commit message box.

Ok, well you can set up a task that does most of this. On Linux with clipit installed, something like this

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "command": "sh",
    "isShellCommand": true,
    "args": ["-c"],
    "showOutput": "always",
    "suppressTaskName": true,
    "echoCommand": true,
    "tasks": [
        {
            "taskName": "Undo last commit",
            "args": ["git show -s --format=%B HEAD | xargs | clipit && git reset HEAD~"]
        }
    ]
}

This copies the commit message to the clipboard before undoing the change. Then you're a mere Ctrl Shift G, Ctrl V away from what you want.

Doesn't it seem a little silly to tell people that the way to enable the "undo last commit" action is to commit other stuff that they don't want committed? At which point the "undo last commit" action would undo that commit, and you still wouldn't be able to undo the one you originally intended to undo?

I understand the caution around merging, but I think maybe we've lost sight of the 90% use case here: I just hit commit by mistake, and I want to undo it. There are no intervening changes, so no merge issue; I just want to undo the commit I did 3 seconds ago. Why must that be impossible (within the editor) just because I have other, unrelated changes? I'd like to dispute the assertion that "most will be annoyed" with supporting the likeliest use case.

Alright guys, you've convinced me. 馃憤

Today, my friends, is a day of celebration :) thanks @joaomoreno

Many thanks @joaomoreno !

Was this page helpful?
0 / 5 - 0 ratings