日期:2017-05-04
起因:想要push一个本地库(写好的)到远程库(新建的)中,报了三次错误,一一记录下来。
错误一,远程库和本地库不匹配,远程仓库比本地库更新,让我们先git pull
一下。
wangweilongdeMac-mini:UUID+Keychain wangweilong$ git push -u origin master
To github.com:Jason-IUVO/UUID-KeyChain.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com:Jason-IUVO/UUID-KeyChain.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
错误二,没有指定分支去pull
,解决方法已经提示我们了:git pull <remote> <branch>
wangweilongdeMac-mini:UUID+Keychain wangweilong$ git pull
warning: no common commits
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (5/5), done.
From github.com:Jason-IUVO/UUID-KeyChain
* [new branch] master -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> master
错误三,拒绝合并非相关联的历史,解决方案:git pull origin master --allow-unrelated-histories
wangweilongdeMac-mini:UUID+Keychain wangweilong$ git pull origin master
Warning: Permanently added the RSA host key for IP address '192.30.255.112' to the list of known hosts.
From github.com:Jason-IUVO/UUID-KeyChain
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories