解决方案:
使用 git checkout --orphan newBranch 清理git历史
操作步骤:
1) 创建新分支
git checkout --orphan newBranch
2) 添加所有文件(除了.gitignore中声明排除的)
git add -A
3) 提交跟踪过的文件(Commit the changes)
git commit -am “init commit”
4) 删除master分支
git branch -D master
5) 重命名当前分支为master
git branch -m master
6) 重新指定远端
git remote set-url origin http://xxx
2024/7/15 11:35:07
git push -f origin master
通过以上几步就可以简单地把一个Git仓库的历史提交记录清除掉了