Git Remove Untracked Files using Command


In order to remove untracked files in Git make use of the git clean command with -i option for interactive mode.

Example:
% git clean -i -f


Would remove the following item:
  HelloWorld.java
  .temp
  index.html
*** Commands ***
    1: clean          
    2: filter by pattern
    3: select by numbers
    4: ask each
    5: quit
    6: help
What now> 1
Removing HelloWorld.java
Removing .temp
Removing index.html
Git Remove Untracked Files using Command
Some Options:
-i (--interactive) --> Interactive Mode
-f (--force) --> Force
-d --> Include directories
-n (--dry-run) --> dry run
-q (--quiet) only report if errors

Read More: https://git-scm.com/docs/git-clean#Documentation/git-clean.txt---force

-


Have Questions? Post them here!

Topics Coverage:


🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.

Follow Us: GitHub | Facebook | Twitter | Instagram