One thing we need to know is that the below method only clear the git commit history. One with git commit history links still can retrieve the info.
The only way to completely clear them is to delete the repository and start afresh. Even doing so, still, there are many git watching sites that have a cache of your git repository.
So be careful, not to git push your password or token file to the git server.
Change the password or revoke the token permissions immediately.
I also used this to clean up my repository after many commits,. git size became very big. Since I do handle the repository alone or private repository, so no problem.
Sometimes git push history is very useful for learning, sometimes it is a sort of memory journal.
Quote from:
https://stackoverflow.com/a/26000395
Deleting the .git folder may cause problems in your git repository. If you want to delete all your commit history but keep the code in its current state, it is very safe to do it as in the following:
# Checkout
git checkout --orphan latest_branch
# Add all the files
git add -A
# Commit the changes
git commit -am "ekapassword v1 enhancements + update jsSHA-3.2.0 2020 etc"
# Delete the branch: use main or master
# git branch -D master
git branch -D main
# Rename the current branch to main
# git branch -m master
git branch -m main
# Finally, force update your repository
# git push -f origin master
git push -f origin main