1. 本地备份(重要)
先把当前代码备份一份,避免误操作导致代码丢失。
2. 删除 Git 历史
删除项目中.git
文件,这样就把当前仓库的 Git 记录全部清空了。
3. 重新初始化 Git
git init
4. 添加远程仓库
git remote add origin https://github.com/你的用户名/仓库名.git
5. 添加并提交代码
git add .
git commit -m "Initial commit"
6. 强制推送到 GitHub
git branch -M main # 如果想用 main 作为默认分支
git push -u origin main --force