How to delete all commit history in git

  1. Deleting the folder first can cause problems in the git repository; .git 
  2. If you want to delete all commit history, but keep the code in its current state, you can do it safely as follows:
  3. try to run ; git checkout --orphan latest_branch 
  4. add all files ; git add -A 
  5. commit changes ; git commit -am "commit message" 
  6. delete branch ; git branch -D master 
  7. rename the current branch ; git branch -m master 
  8. Finally, force an update of the repository: . git push -f origin master 
  9. complete!
{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324034476&siteId=291194637