Skip to content

GitHub Tips

Valk edited this page Oct 9, 2024 · 1 revision

How to Remove Files on GitHub but not Locally

For example if you accidentally committed a ton of .zip files you can remove them from GitHub with the following command.

git rm --cached **/*.zip

If you accidentally committed to a detached head, here is how you can recover your work.

Move your commits to a new branch

git switch -c my-temporary-work

Switch to the main branch

git switch main

Merge your commits from the temporary branch with the main branch

git merge my-temporary-work

Delete temporary branch

git branch -d my-temporary-work