Clean
From time to time, you'll find that there are untracked files listed in your status. 99% of the time these will be files you created and you'll want them to be tracked, which you do by adding them to the index (as shown previously). There are times, however, when you may find untracked files that you don't want:
Figure 10.15: Untracked files
In this case, we have a couple choices. We can add Untracked.cs
to the index or we can get rid of it. To do so, we try git clean
:
Figure 10.16: Using clean to remove untracked files (fails)
Because git clean
is one of the few truly destructive commands—once called, the untracked files are gone, never to be seen again—Git comes back with the snarky reply that it is "refusing to clean." To actually clean, Git requires that you tell it you really mean it by using the -f
(force) flag:
Figure 10.17: Using clean as above, but with the force flag (succeeds)
The -f
flag...