For Tracked Files (Use git rm) (+2)
For Tracked Files (Use git rm)
# Remove tracked file
git rm path/to/file
# Remove tracked directory
git rm -r path/to/directory
# Remove from git but keep local copy
git rm --cached path/to/file
For Untracked Files (Use rm)
# Remove untracked file
rm path/to/file
# Remove untracked directory
rm -rf path/to/directory
# Interactive removal (safer)
rm -i path/to/file
Dry Run First
# Preview what would be deleted
git clean -n -d
# Preview including ignored files
git clean -n -d -x