以前在连接远程仓库的时候都是是先clone一个本地新仓库再把文件复制过去,这次感觉太麻烦,想把创建完的项目直接连接到仓库,然后就error了。
参考
- fatal: remote origin already exists.解决方法
- 解决办法:error: failed to push some refs to ‘https://github.com/xxxx.git’
错误代码
error: failed to push some refs to 'https://github.com/xxxxxx.git'
解决方案
因为在那之前我进行了多次尝试,所以可能会报这个错fatal: remote origin already exists.
所以首先需要断开之前的连接:
git remote rm origin
然后连接:
1 | git remote add origin https://github.com/xxxxxx.git |
这个时候就会报前面说的错误了 error: failed to push some refs to 'https://github.com/xxxxxx.git'
一开始我先尝试 git pull origin master 了一次再push还是报错,错误原因我自己分析了一下还是因为文件冲突了,但是为什么pull了没用还是暂时没有想清楚,所以没办法只能强制push:
git push -u origin master -f
这样就没有报错了,然后依次add,commit,push就成功了。
Author:oCodeHoney
Date:2020-6-9