Bald Bearded Builder
git/what-is-git-clean

What is git clean 🤯

`git clean` removes untracked files, with flags controlling forced deletion, untracked directories, and ignored files.

Loads from YouTube when you press play

Transcript 1 topic

Git clean basics

0:00

Git clean is a seldom used command that removes untracked changes from the working tree. Let's say you have files that aren't tracked by Git, meaning you haven't done any commits or even done a git add with those yet. Git clean will remove those files. Because it's going be deleting files, it normally wants a dash f or force parameter provided. By default when you run it, it's going to try and go recursively through all the directories it knows about, but it won't try to go into untracked directories.

For that, you would need the dash d parameter. Just like a git commit or a git add, it respects the git ignore file. If you did want to get rid of those things, you could pass it the dash x parameter. Git clean is pretty new to me. I'm curious if you're using it already.

It's one of those things that I never knew I needed until I knew it existed. I've been deleting that stuff manually for years.

Sign in to join in. Reading needs nothing.