本地没有需要提交代码,可以删库,重新clone,不删库方案如下
不删库方案
- 移除原有origin, git remote rm origin
- 添加新的origin url, git remote add origin [URL]
- 映射本地分支与远程分支 git branch --set-upstream-to=origin/[远程分支] [本地分支], 自行替换自己分支
以上即可完成本地与远程映射,
特殊状况
- 如果分支映射失败,请检查远程分支是否丢失,丢失请自行建立分支
- 注意查看git的提示信息, 如果远程分支存在,那应该只是远程分支在本地没有同步,执行git remote update origin 重新更新远程分支列表
- 再次执行分支映射即可
hint:
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run “git fetch” to retrieve it.
hint:
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: “git push -u” to set the upstream config as you push.