Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Undo Commit button #2564

Closed
phizch opened this issue Nov 15, 2020 · 3 comments
Closed

Suggestion: Undo Commit button #2564

phizch opened this issue Nov 15, 2020 · 3 comments

Comments

@phizch
Copy link

@phizch phizch commented Nov 15, 2020

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

  • It would be very useful to have an "Undo Commit" button so that I can easily fix my mistake.
  • Ctrl+Z could 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.
  • An alternative is an option to only allow commits of staged files. That way I wouldn't forget to do the staging. Since it would be a necessary step it would impossible to "accidentally" stage all files instead of just some.

The state after the "Undo Commit" should be the state before clicking the "Commit" button, preferably with the written commit message.
The Undo Commit button/command would run git reset HEAD~1 with the correct option (probably --soft, but I may be mistaken).

Alternatives

From my mistakes and subsequent web-searches, I know git reset --soft HEAD~1 basically 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 suspect git reset --hard HEAD~1 would 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 undo command. 😉

@phizch
Copy link
Author

@phizch phizch commented Nov 15, 2020

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.
Git is an extremely powerful tool, but it's also challenging to use. Part of this is the permanency of it - anything committed should stay committed, and commits should be meaningful. But I find it hard to justify committing, or I forget committing. And I often have different changes that should be committed separately by staging, but then I mess up and commit the entire thing, get frustrated and bang my head against a wall for sometime before calming down and fix the mess.

Anyway - I'll stop here before I make a complete blog out of it.

@phizch
Copy link
Author

@phizch phizch commented Nov 15, 2020

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.

@jcansdale
Copy link
Collaborator

@jcansdale jcansdale commented Nov 18, 2020

Hi @phizch,

I think this is part of Visual Studio's new Git experience. You can find more information here:
https://devblogs.microsoft.com/visualstudio/announcing-the-release-of-the-git-experience-in-visual-studio

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.

@jcansdale jcansdale closed this Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.