The example creates a new Git repository in the
git_clean_test directory. It then proceeds to create a
tracked_file which is added to the Git index, additionally, an
untracked_file is created, and an
untracked_dir. The example then invokes
git status which displays output indicating Git's internal state of tracked and untracked changes. With the repository in this state, we can execute the
git clean command to demonstrate its intended purpose.
$ git clean fatal: clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean
At this point, executing the default
git clean command may produce a fatal error. The example above demonstrates what this may look like. By default, Git is globally configured to require that
git clean be passed a "force" option to initiate. This is an important safety mechanism. When finally executed
git clean is not undo-able. When fully executed,
git clean will make a hard filesystem deletion, similar to executing the command line rm utility. Make sure you really want to delete the untracked files before you run it.