how to delete all commit history in github?

This question already has an answer here:

  • Make the current commit the only (initial) commit in a Git repository?

    13 answers

  • Is `git rebase master` always followed by `git pull --rebase` and then `git push --force`?
  • How to add already cloned projects as submodules?
  • git no pager for specific commands
  • Fail to clone repository with git lfs
  • How to customize which terminal is used by the “Git Bash Here” command of msysgit's shell extension?
  • Passing a list of arguments to docker at build / run time
  • Git Permission Denied
  • How can I see what I am about to push with git?
  • git svn clone has been running for a very long time. Is there a way to prove it's not stuck in an infinite loop?
  • Run autotests as a result of clicking 'merge pull request' button
  • git clone with https error - fatal: repository not found
  • Jenkins + Git plugin CheckoutConflictException
  • 2 Solutions collect form web for “how to delete all commit history in github?”

    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:

    1. Checkout

      git checkout --orphan latest_branch

    2. Add all the files

      git add -A

    3. Commit the changes

      git commit -am "commit message"

    4. Delete the branch

      git branch -D master

    5. Rename the current branch to master

      git branch -m master

    6. Finally, force update your repository

      git push -f origin master

    PS: this will not keep your old commit history around

    If you are sure you want to remove all commit history, simply delete the .git directory in your project root (note that it’s hidden). Then initialize a new repository in the same folder and link it to the GitHub repository:

    git init
    git remote add origin

    now commit your current version of code

    git add *
    git commit -am 'message'

    and finally force the update to GitHub:

    git push -f origin master

    However, I suggest backing up the history (the .git folder in the repository) before taking these steps!

    Git Baby is a git and github fan, let's start git clone.