参考: - https://www.lmonkey.com/t/WMLDp7VLY - https://blog.csdn.net/lx11573/article/details/126127542
- 新建一个空白分支(假设旧分支名字为 master)
git checkout --orphan new_branch
通过 git status
查看当前分支的文件状态,发现文件都为待添加状态,可以选择添加这些文件,也可以直接忽略。
- 删除旧本地分支 master
git branch -D master
- 将当前新的分支重命名为 master
git branch -m master
- 进行强制提交到远程仓库
git push -f origin master
可能遇到的问题
This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/pre-push.
执行 rm -rf .git/hooks/pre-push
删除这个 hook 即可