To remove files from your local Git repository that shouldn't be committed - such as untracked files or those matching .gitignore patterns - use Git's built-in commands like git clean . These steps focus on safely cleaning your working directory without affecting committed history or remote repositories. Verify .gitignore Setup Ensure your .gitignore file lists patterns for files not to commit, like node_modules/ , *.log , or env/ . Run git status --ignored to see ignored files alongside untracked ones. stackoverflow +1 Dry Run Untracked Files Preview files Git would remove with git clean -n -d This shows untracked files and directories (non-ignored) without deleting anything. datacamp +1 Dry Run Ignored Files To preview ignored files (matching .gitignore ), use git clean -n -d -x Review the list carefully, as it includes build artifacts or configs. atlassian +1 Clean Untracked Files Remove untracked files and directories: git clean -f -d Add -x to ...