项目场景:

Git bash


问题描述:

进行git remote add origin https://github.com/你的用户名/你的用户名.github.io.git命令时

出现错误:error: remote origin already exists


原因分析:

与本地仓库关联的远程仓库已经存在,无法进行新的关联


解决方案:

  1. 删除已关联的远程库
git remote rm origin 
  1. 关联正确的远程仓库
git remote add origin https://github.com/你的用户名/你的用户名.github.io.git
  1. 推送到正确的仓库
git push -f origin main