Step 1: remove all history (WARNING: can’t be undone!)

cd repo
rm -rf .git

Step 2: reconstruct git repo

git init
git add .
git commit -m "Deleted git history"

Step 3: push to GitHub

git remote add origin <repo-url>
git push -u --force origin master

Note:
You can replace <repo-url> above with:

  • your repository URL (eg. https://github.com/oddleaf/oddleaf.github.io)
  • or something like git@github.com:<username>/<repo>.git (eg. git@github.com:oddleaf/oddleaf.github.io.git)

When pushing next time, you can simply use:

git push

Source: StackOverflow