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

Overcommit should emit a warning when issuing "git reset --hard" or "git stash" #711

Closed
jbbarth opened this issue Apr 1, 2020 · 3 comments

Comments

@jbbarth
Copy link

jbbarth commented Apr 1, 2020

Today I got pretty mad at overcommit when issuing a "Ctrl+C" during a pre-commit hook and I saw I've just lost all my work.... Just to understand 5 minutes later that it was stashed and I could recover it easily. See some explanations in #80

I think overcommit should issue an explicit message when doing frightening operations like this, maybe with some guidance to recover your work before you get as mad as I was.

Note that it's not something that happens only in rare cases when you change your mind when doing git commit. Overcommit has the (awesome!) ability to run rubocop only on modified lines, as long as other goodies, so I frequently have a second window running watch .git/hooks/pre-commit, and as soon as I "Ctrl+C" on that window to stop watching, I take the risk of such a git reset --hard or git stash if I understand the behavior correctly.

What do you think ? Happy to work on a PR if you think the idea is worth it.

@jbbarth jbbarth changed the title Overcommit should emit a warning when issuing "git reset --hard" Overcommit should emit a warning when issuing "git reset --hard" or "git stash" Apr 1, 2020
@jbbarth
Copy link
Author

jbbarth commented Apr 1, 2020

OK, I just saw that it seems stashing is part of normal overcommit behavior if some changes are not staged. My overall comment still stands I think, but I definitely think I don't have enough insights about overcommit implementation, so I'd be more than happy if someone can clarify all this :-)

@sds sds closed this as completed in a15edd2 Apr 6, 2020
@sds
Copy link
Owner

sds commented Apr 6, 2020

Thanks for the feedback! Added a quick note to remind users to check their stash. There are good reasons why we reset in this way but it's understandable that without the necessary context it seems wrong. See this explanation—hope it clarifies.

@jbbarth
Copy link
Author

jbbarth commented Apr 12, 2020

Thanks a lot, I’m sure it will help others ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants