Skip to main content
Photo of DeepakNess DeepakNess

Remove mistakenly pushed files from GitHub

Unproofread notes

I accidentally pushed an incomplete blog post .md file to GitHub for my personal blog, and then had to remove from GitHub without deleting it locally. So I looked it up, and this is how it's done:

  1. Remove the file from Git tracking (but keep it locally)
git rm --cached content/blog/still-brave-browser/index.md
  1. Commit the removal
git commit -m "Commit message"
  1. Push the changes to GitHub
git push origin main

Basically, the git rm --cached command removes the file from Git's tracking without deleting it from your local filesystem, so you can continue editing it.

Comment via email