error: failed to push some refs to ‘github.com:xxxxx.git’
问题
使用git时,若在远程创建了一仓库,本地也创建了一个仓库。即本地仓库和远程仓库是两个独立仓库时,使用git push -u origin master
后会报如下错误:
error: failed to push some refs to ‘github.com:xxxxxx.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.
hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.
解决
在push之前拉取远程时,使用下面的命令
git pull origin master --allow-unrelated-histories
之后再add , commit ,push 操作即可。