Skip to content

Instantly share code, notes, and snippets.

@chengengliu
Last active March 10, 2021 03:18
Show Gist options
  • Save chengengliu/fcd484f7e7fb1ff95f20c10ab46d9f61 to your computer and use it in GitHub Desktop.
Save chengengliu/fcd484f7e7fb1ff95f20c10ab46d9f61 to your computer and use it in GitHub Desktop.
Remove commits remotely without touch local files

Thanks to Stackoverflow

Remove files based on .gitignore:
git rm --cached `git ls-files -i -X .gitignore`

Remove a single file: git rm --cached mylogfile.log

If it's a directory, just add -r to recusively rm it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment