-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Please add more safeguards to git clear
#1167
Comments
Hello! Thanks for the report; I've made a PR that writes part of the warning in uppercase characters. I haven't implemented the red colors part and printing the list of files since that is slightly less straightfoward. (printing red colors should only be done conditionally (only if stdin is a tty), and that requires some common logic, which this repository isn't quite set up for). In the future, hopefully more can be done |
There is a |
@hyperupcall Hi, thank you so much for responding to this issue and making a PR quickly. This PR is good, capital letters are a good start.
I understand, you've tackled a part of the problem quickly. I'm hoping that the next PR will have asking the user to confirm (y/N) a second time, because that would also be quick and easy to implement. The red colored text should first check if the terminal supports colored text and only then print it. And as for listing the files, git clear already prints the list of files after the command has been executed. So the logic needs to just be tweaked slightly to print the list of files affected before the command is finished, as seen in this image Hope this helps 👍 |
This might help as a reference for adding red colored text in the terminal: https://jvns.ca/blog/2024/10/01/terminal-colours/ |
Hi,
This issue is in regards to the
git clear
command.I was showing
git extras
to some people today using thegit repl
. I typedclear
to clear the text in the repl. It asked me if I was Sure. I thought it was asking me if I was sure that I wanted to clear my screen. I didn't think for more than a few seconds about it and I typed "y" for yes. It didn't clear my screen. What it actually did was hard delete 4 files worth of code that existed only in that directory with no other copies.I do realise that this is my mistake and that I was in a rush, so I didn't pay enough attention.
However, I still want to urge @tj and team to add some more loud safeguards to
git clear
so that users understand that the action they are about to take is absolutely irreversible and will delete un-tracked code. I would suggest doing this by:Sure? - This command may delete files that cannot be recovered, including those in .gitignore [y/N]:
in CAPITAL and red color letters.Thank you. I sincerely hope you act on this.
The text was updated successfully, but these errors were encountered: