Here I am solving this question with a brute-force approach.
Note: This approach will not work if your repository has submodules. For repository having submodules, you should use interactive rebase.
Let’s see the brute-force approach
Remove all history(make sure you have the backup) using:
cat .git/config # note <github-url>
rm -rf .git
Reconstruct the git repo with the current content:
git init
git add .
git commit -m "Initial commit"
Push the commit to github
git remote add origin <github-url>
git push -u --force origin master
Thus, you can make current commit to the only commit in a git repository.