Languages
[Edit]
EN

Git - remove untracked files

6 points
Created by:
Dragontry
371

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:

  1. 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)
  2. clean untracked files
    git clean -fd

    Output:

    Removing logs/
  3. 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

Git

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

â€ïžđŸ’» 🙂

Join