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


This is not an AI-generated article but is demonstrated by a human on an M1 Mac running macOS Ventura 13.

Please support independent contributors like Code2care by donating a coffee.

Buy me a coffee!

Buy Code2care a Coffee!

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org



















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap