git: Remove Untracked Files

Publikováno: 19.11.2020

I’ve always said that I know just enough about git to get the job done, but also do something destructive. Nothing embodies that more than my recent mistake. I somehow found a git repository full of untracked files and git stash wouldn’t fix it. Desperation led me to learning how to remove all untracked files, […]

The post git: Remove Untracked Files appeared first on David Walsh Blog.

Celý článek

I’ve always said that I know just enough about git to get the job done, but also do something destructive. Nothing embodies that more than my recent mistake. I somehow found a git repository full of untracked files and git stash wouldn’t fix it. Desperation led me to learning how to remove all untracked files, the same way hg purge does for mercurial.

To remove untracked files and directories, you can execute:

# Remove untracked directories
git clean -fd

# Remove only untracked files
git clean -fX

There you have it — you’ve removed your untracked files. The dangerous side? It will also delete files hidden by .gitignore when you run a git status. Be careful when removing untracked files!

The post git: Remove Untracked Files appeared first on David Walsh Blog.

Nahoru
Tento web používá k poskytování služeb a analýze návštěvnosti soubory cookie. Používáním tohoto webu s tímto souhlasíte. Další informace