1.问:错误 failed to push some refs to ‘xxxx’...
error: failed to push some refs to 'codemanager@xxx.xxx.xxx.9:xxxxxx/ProjectFiles.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again
(提示大概就是,你的仓库无法推送到远程处,需要你pull一下远程分支)
(1)情景再现
git创建远程仓库,并生成了README.md文件,现在本地项目目录处初始化git,执行命令后将本地仓库推到远程仓库。
(2)git命令执行
git init
git add .
git commit -m "推"
git remote add origin [remote-addr]
git push -u origin master
(3)错误原因
在push到远程之前,需要执行命令 'git pull origin master' 关联一下远程仓库。
2.问:错误 fatal: refusing to merge unrelated histories(致命:拒绝合并不相关的历史记录)
(1)情景再现
git创建远程仓库,并生成了README.md文件,现在本地项目目录处初始化git,执行命令后将本地仓库推到远程仓库。
(2)git命令执行
git init
git add .
git commit -m "推"
git remote add origin [remote-addr]
git pull origin master
基于上面的问题解决,在执行pull的命令的时候又报错了,这时候需要在命令后加上 '--allow-unrelated-histories',消除它们的历史分歧,达到合体目的。
即 'git pull origin master --allow-unrelated-histories'
然后再继续执行 'git push -u origin master'
(遇到问题,持续更新...)