question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

git reset --soft HEAD~1

See original GitHub issue

Sometimes, 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:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
nunoperaltacommented, Jan 30, 2020

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 😃

1reaction
nunoperaltacommented, Jan 30, 2020

@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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Undo the Last Commit Using Git Reset Command
git reset changes where the current branch is pointing to ( HEAD ). HEAD is a pointer or a reference to the last...
Read more >
git-reset Documentation - Git
Resets the index and updates the files in the working tree that are different between <commit> and HEAD , but keeps those which...
Read more >
Git Reset | Hard, Soft & Mixed | Learn Git - GitKraken
Git reset allows you to move the HEAD to a previous commit, undoing the changes between your starting state and specified commit. Learn...
Read more >
How To Git Reset to HEAD - devconnected
To soft reset files to HEAD on Git, use the “git reset” command with the “–soft” option and specify the HEAD. ... Contrary...
Read more >
Git Reset | Atlassian Git Tutorial
The default invocation of git reset has implicit arguments of --mixed and HEAD . This means executing git reset is equivalent to executing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found