Skip to content

Instantly share code, notes, and snippets.

@tonyfraser
Last active July 22, 2019 05:14
Show Gist options
  • Save tonyfraser/a09b9dea589d57e2848409effe647496 to your computer and use it in GitHub Desktop.
Save tonyfraser/a09b9dea589d57e2848409effe647496 to your computer and use it in GitHub Desktop.
This is how you remove unwanted files and/or directories from commit history on github.com.
# Get your files ignored correctly on the file system and website, keep checking until
# the latest commit is perfect.
639 vi ./.gitignore
640 git rm -r --cached .
641 git add -A
642 git commit -m "adding"
643 git push origin master
# now create a temp branch off master, then delete the master, and push master back up again.
# https://tecadmin.net/delete-commit-history-in-github/
653 git checkout --orphan temp_branch
654 git branch
655 git add -A
656 git commit -am "the first commit"
657 git branch -D master
658 git branch -m master
659 git push -f origin master
# presto -- all those commits are gone on the website.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment