git reset --soft HEAD~1
See original GitHub issueSometimes, I accidentally commit into a Branch I don’t have permission to. This is because I need to create a new branch, switch to it, commit my changes there, and do a pull request.
When this accident happens, I always have to Google how to undo a commit: git reset --soft HEAD~1
Because, when I use the “Revert this commit” option, GitHub Desktop does not keep the changes staged and automatically creates an extra commit.
The “Undo” button has already disappeared, and when that happens, I have absolutely no way to do this through GitHub Desktop. I have to use the command line instead.
–
My suggestion is to split the option “Revert this commit” into two:
- Revert this commit
- Undo this commit
The “Undo this commit” can be available only to the last commit, and only if it hasn’t been pushed to origin yet. (if that makes sense?)
–
Context images below:
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Hello. I tried this today, with the new release, and it’s definitely better now. I could Undo after attempting a push, and follow the proper workflow without having to leave the UI 😃
@billygriffin - although I’m ok with the solution, it’s strange that I do not get the same “protected” warning as described in the blog entry. I definitely have the version released yesterday (and a hotfix today).
I’m using Azure DevOps, and only when I attempt to Push, I get a huge error in a popup. Thankfully, I can Undo the commit and switch to another branch, but I don’t see the “protected” warning below the commit box.
Just saying, in case this could be some bug.
Thanks!