[git] fatal: clean.requireForce defaults to true nor -f given; refusing to clean


Git-Clean-Command.
% git clean

fatal: clean.requireForce defaults to true 
and neither -i, -n, nor -f given; refusing to clean

You will get this error when you try to clean your git local working directory if,

  • You have set the clean.requireForce value as false in the .gitconfig local/global file, or,
  • You have not set clean.requireForce in the .gitconfig local/global file.
Solution(s):
  • Set clean.requireForce as true in the config file.
  • execute: git clean -n : to just tell which all files will be cleaned (dry run)
  • execute: git clean -i : to get into interactive mode.
  • execute: git clean -f: To force clean (overrides whats set in config file)
Example:
$ git clean -i
Would remove the following item:
  d.txt
*** Commands ***
    1: clean                2: filter by pattern    3: select by numbers
    4: ask each             5: quit                 6: help
What now> c
Removing d.txt
Advertisements
Try Out Code2care Dev Tools:

Advertisements

Advertisements
Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.