日期:2017-05-04
起因:想要push一個(gè)本地庫(kù)(寫(xiě)好的)到遠(yuǎn)程庫(kù)(新建的)中题篷,報(bào)了三次錯(cuò)誤,一一記錄下來(lái)屡穗。
錯(cuò)誤一贴捡,遠(yuǎn)程庫(kù)和本地庫(kù)不匹配,遠(yuǎn)程倉(cāng)庫(kù)比本地庫(kù)更新村砂,讓我們先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.
錯(cuò)誤二,沒(méi)有指定分支去pull
箍镜,解決方法已經(jīng)提示我們了: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
錯(cuò)誤三源祈,拒絕合并非相關(guān)聯(lián)的歷史,解決方案: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