How to make the current commit the only (initial) commit in a Git repository ?
Here's the brute-force approach. It also removes the configuration of the repository.
Note: This does NOT work if the repository has submodules! If you are using submodules, you should use e.g. interactive rebase
-
Remove all history
rm -rf .git
-
Reconstruct the Git repo with only the current content
git init git add . git commit -m "Initial commit"
-
Push to GitHub.
git remote add origin <github-uri> git push -u --force origin master
-
Done.