Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Suggestion: Undo Commit button #2564
Comments
|
As mentioned, I'm relatively inexperienced with Git and GitHub. I've worked on probably over 100 personal projects, but I've not put a single one of them on GitHub, and only a handful actually use git or any other source control. The main reason for this is that I find git intimidating, and anything that makes it simpler to use would be a good thing, for me, and probably for many other people. I know that programming is a very technical profession and/or hobby, but the tools should be as user friendly as possible. Anyway - I'll stop here before I make a complete blog out of it. |
|
I know that this may be in the totally wrong repository.. If it is, please let me know where I actually should submit the issue.. This was the closest thing I could find. |
|
Hi @phizch, I think this is part of Visual Studio's new Git experience. You can find more information here: You could add a comment there or use the feedback options at the bottom of the post. I hope that helps! Note, I'm going to close this issue because this functionality isn't part of GitHub for Visual Studio. |
Problem:
As a relatively fresh user of Git I've several times accidentally committed all changes instead of just one file.
This is very frustrating because every time I have to make sure that I correctly undo the changes manually, and I get freaked out because I'm scared I'll lose my work if I do it incorrectly (e.g. deleting the commit without restoring the files).
Solutions
Ctrl+Zcould also be an option, but if the keyboard focus is in the text editor instead of the Git Changes window, that could make things even worse by changing a file.The state after the "Undo Commit" should be the state before clicking the "Commit" button, preferably with the written commit message.
The
Undo Commitbutton/command would rungit reset HEAD~1with the correct option (probably--soft, but I may be mistaken).Alternatives
From my mistakes and subsequent web-searches, I know
git reset --soft HEAD~1basically undoes the commit, but I have to use the command line git tools to do that, and I have to look up on the web the correct commands so that I don't accidentally destroy all the changes I've made - I suspectgit reset --hard HEAD~1would to that, but I'm not sure.It also leaves all changes in a staged state, so unstaging them is another step that could lead to mistakes.
And it also doesn't preserve the commit message.
There are probably good external tools out there, and I've even considered writing my own tool for fixing my common mistakes.😉
But it would be much better if Visual Studio's Git tools were enough. I mean, it's almost 2021, and practically all software has an
undocommand.The text was updated successfully, but these errors were encountered: