How do you remove commit history in GitHub

Background

In some circumstances it will make sense to remove commit history from a GitHub repo. On public repositories you might want to do this if you have previously had a private repo, but you don’t wish the public to see history of the code.

Steps to Remove Commit History from GitHub

Here are the steps for removing the commit history:

  1. Checkoutgit checkout --orphan latest_branch
  2. Add all the filesgit add -A
  3. Commit the changesgit commit -am "commit message"
  4. Delete the branchgit branch -D master
  5. Rename the current branch to mastergit branch -m master
  6. Finally, force update your repositorygit push -f origin master

Warning: Your commit history is now history.

References

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top