1、检查现有远程源
git remote -v
2、添加新的 GitHub 远程仓库,我们不删旧的,先新建一个远程,叫 github
git remote add github https://github.com/yourname/aigc_client_vue.git
3、确认当前主分支
git branch
4、那我们改名成 main
git branch -m master main
5、把所有提交记录推送到 GitHub(包括分支和 tag)
# 推送所有分支
git push github --all
# 推送所有标签
git push github --tags
6、如果远程仓库有内容,可以选择保留本地历史,覆盖 GitHub 仓库
# 强制推送所有分支,覆盖远程
git push github --all --force
# 同步标签(可选)
git push github --tags --force
7、或者保留 GitHub 的内容,并合并历史
7.1 那你可以先把 GitHub 的改动拉下来合并
git pull github main --allow-unrelated-histories
Git 会提示你进入合并编辑器,你保存退出即可,然后再推送上去.
git push github main