Removing non-repository files with git?

Git

Git Problem Overview


I'm writing Autotools code and in the process of development, tons of files are generated.

Is there anyway to tell git to remove all files from a directory that are not part of the repository?

Git Solutions


Solution 1 - Git

You can use git-clean. This command will remove untracked files/directories. By default, it will only print what it would have removed, without actually removing them.

Given the -f flag to remove the files, and the -d flag to remove empty directories as well :

git clean -df

Also removing ignored files :

git clean -dfx

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionScottView Question on Stackoverflow
Solution 1 - GitLily BallardView Answer on Stackoverflow