You might be familiar with
rm -rf and if you are, you probably also were warned to be very careful. So I’m pretty cautious about deletions for fear of accidentally deleting directories. Generally I’m not deleting a lot of files, so a simple
git rm /path/to/file will suit just fine. However if you find yourself in a situation where you’re trying to bulk delete files, deleting each file is quite tedious.
You also might have noticed that when you do a
git add . only the staged, modified files get added and you get the following message: “(use “git add/rm <file>…” to update what will be committed)”
So here’s how you bulk delete files:
See what is actually staged via
git status(btw this is generally a good practice). I’m assuming that your deleted files are “not staged for commit”.
Stage your deleted files –
git add -u
Confirm that your deleted files are staged –
Commit your now staged deleted files –
git commit -m "your_message"
Push your commit like normal –
Hope everyone is staying warm this winter!