Git clean -f -d

Important note:

Be careful with the following commands, they delete files permanently!

Explanation:

If you want to just remove all untracked files inside:

  • The main root directory
  • Or other already tracked (committed) directories

Just run this:

git clean -f

Note 1:

  • In the following commands, -f means force.
  • Also the new (untracked) files that are inside the new (untracked) directories will not be removed by the above command.

If you want to remove 1) untracked directories with 2) all their contents, in addition to what is done by git clean -f , you need to run:

git clean -f -d

Note 2:

If you stage a new file, it is no longer an untracked file. Remember we can stage a file with git add file_name.

With a staged file, the above commands git clean -f or git clean -f -d will not work.

Posting about Python and Laravel

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Speech Recognition Project

How I Get Into Coding and Why You Should Learn to Code Too

Intro to Version control, GitHub, and Local environments

Why is Cubbit different to blockchain, IPFS and personal cloud storage devices like Lima?

Building a CV Builder with BIRT in KNIME — Part 1

How to setup Grafana with LDAP in k8s using Helm

GCP — Deploying Angular App with NodeJS API on GKE Autopilot

Authoring Swift PlaygroundBooks — part 1

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Panjeh

Panjeh

Posting about Python and Laravel

More from Medium

Wondering How To Buy Stellar Lumens In Canada? Here’s A Comparison Between Stellar And Ripple?

How to make a game engine in C#

Hosting a FullStack Javascript Web App on Digital Ocean Part 1

How to Develop Linux Applications (Part 2)