EN
Git - remove untracked files
6
points
In this short article we would like to show how to remove untracked files using Git in command line.
Run following command:
git clean -fd
Where -fd
means: clean files and directories.
Practical example
Let's suppose we want to remove logs
directory.
Simple steps:
- check if some files are untracked
git status
Output:
On branch master Your branch is up to date with 'origin/master'. Untracked files: (use "git add <file>..." to include in what will be committed) logs/ nothing added to commit but untracked files present (use "git add" to track)
- clean untracked files
git clean -fd
Output:
Removing logs/
- check if files were removed:
git status
Output:
On branch master Your branch is up to date with 'origin/master'. nothing to commit, working tree clean