tj / tj/git-extras

Please add more safeguards to `git clear`

Open
#1,167 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Shell
Stars
18.1k
Forks
1.2k
Avg merge
5d 17h
Merged PRs (30d)
1

Description

Hi,

This issue is in regards to the git clear command.

I was showing git extras to some people today using the git repl. I typed clear 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:

  1. Printing the line Sure? - This command may delete files that cannot be recovered, including those in .gitignore [y/N]: in CAPITAL and red color letters.
  2. Asking the user a second time just to make sure. And printing the list of files that are about to be affected by this command.

Thank you. I sincerely hope you act on this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue targets the git clear command documented in Commands.md; start by tracing that command from the git repl and reviewing its current confirmation prompt. Done means the warning explicitly mentions irreversible deletion and .gitignore files, a second confirmation is required, and affected files are listed.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, shell
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.