1. Go to the warehouse and pull a branch such as latest_branch
git checkout --orphan latest_branch
- --orphan create an orphan branch without any history
2. Add all files to the above branch and submit once
git add -A
git commit -am 'initial commit'
3. Delete the master branch
git branch -D master
4. Change the current branch to the master branch
git branch -m master
5. Push all local changes to the remote warehouse
git push -f origin master
- -f force push
6. Associate the local master to the remote master
git branch --set-upstream-to=origin/master
For gitee users, because gitee currently limits the size of a single warehouse to 1024 MB, after clearing the history, you need to go to the project homepage to do a repository GC