WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Git · Intermediate · question 23 of 100

How do you remove untracked files from your working directory?

📕 Buy this interview preparation book: 100 Git questions & answers — PDF + EPUB for $5

In Git, untracked files are files that are not part of the repository and have not been added to the staging area. If you want to remove untracked files from your working directory, you can use the git clean command. The git clean command removes untracked files from the working directory.

Before running the git clean command, it’s a good idea to check which files will be removed. You can use the -n or –dry-run option to do this:

    # Dry run to see which files will be removed
    git clean -n

This command will show you a list of untracked files that will be removed if you run the git clean command.

To remove untracked files from the working directory, use the -f or –force option with the git clean command:

    # Remove untracked files from the working directory
    git clean -f

This command will remove all untracked files from the working directory.

If you want to remove untracked directories as well as files, use the -d option:

    # Remove untracked directories as well as files
    git clean -fd

This command will remove all untracked files and directories from the working directory.

It’s important to note that the git clean command permanently deletes files and directories, so make sure you really want to delete them before running this command.

In summary, you can remove untracked files from your working directory in Git using the git clean command with the -f or –force option. The git clean command permanently deletes files and directories, so use it with caution.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Git interview — then scores it.
📞 Practice Git — free 15 min
📕 Buy this interview preparation book: 100 Git questions & answers — PDF + EPUB for $5

All 100 Git questions · All topics