[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
Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap