How To Remove Untracked Files In Git?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/how-to-remove-untracked-files-in-git/
PINTEREST
PINTEREST
INSTAGRAM

As Git source code versioning software uses tracked and untracked terms to track files. We untracked files are generally added newly to the repository but there may be some bulk files those are unnecessary to version. In this tutorial, we will learn different ways to remove untracked files with Git.

List Files To Be Deleted

Before deleting untracked files and folders we will list untracked files and folders. We will use clean command with the -n option like below.

List Files To Be Deleted
List Files To Be Deleted

Delete or Remove Untracked Files and Folders Forcibly

The most basic way to remove untracked files and folders is using clean git command with the -f option like below. -f means remove and clean forcibly without asking anything.

Delete or Remove Untracked Files and Folders Forcibly
Delete or Remove Untracked Files and Folders Forcibly

Remove Untracked Directories Only

If we just need to remove or delete untracked directories we shouşd use -d option with the remove command. -d simply means removing only untracked directories.

Remove Untracked Files Only

If we just want to remove untracked files only we need to use -X option like below.

Simulate Remove Of Untracked Files and Directories with Dry Run

Removing untracked files and directories may be a critical job where we can lose our latest work. So we can simulate or dry run removing untacked files with the --dry-run option like below.

Simulate Remove Of Untracked Files and Directories with Dry Run
Simulate Remove Of Untracked Files and Directories with Dry Run

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/how-to-remove-untracked-files-in-git/
PINTEREST
PINTEREST
INSTAGRAM
LEARN MORE  How To Create and Manage New Branch with Git?