Tonight I cleaned out my site's repo on GitHub. Over the months, old backup copies of pages and a few test files had piled up in the folder the site is served from, and anything in that folder is public. There were about thirty of them.
GitHub's website will delete a file, but only one at a time, and every delete is its own commit. My site deploys from GitHub, so each of those commits would also start a new deploy. Thirty files, thirty deploys. No thanks.
Press the period key
On any repo page on github.com, press . (the period key). GitHub opens the repo in a full VS Code editor right in the browser, at github.dev. There's nothing to install. Changing github.com to github.dev in the address bar does the same thing, and so does going to vscode.dev/github/you/yourrepo.
Delete in bulk
- In the Explorer on the left, open the folder you're cleaning up.
- Ctrl+click each file or folder you want gone (Cmd+click on a Mac). Shift+click selects a whole range.
- Right-click any of the selected items and choose Delete. Confirm if it asks.
Nothing has changed on GitHub yet. The deletes only exist in the editor until you commit.
Commit once
- Click the Source Control icon, the third one down on the far left. It shows a count of your changes.
- Check the list. Every file you deleted shows up crossed out, with a D next to it.
- Type a message, such as "Remove old backups", and click Commit & Push.
That's one commit, and one deploy.
Bonus: move a file up a folder
I also had one file I wanted to keep in the repo but off the website, so it needed to move up two folders. On the regular github.com site, open the file and click the pencil to edit it. Click at the very start of the filename box and type ../ once for each folder you want to move up. I pressed Backspace there instead, which pulls the folder names back into the box so you can delete them. Either way, the folder path shown next to the box tells you where the file will land. Then commit.
Fair warning
There's no undo button, and the commit goes straight to your live branch. Check the Source Control list before you push. If you do delete the wrong thing, Git still has it. Open the repo's commit history, find the file in the commit before the delete, and add it back.
At any rate, it beat thirty rounds of clicking Delete file.