git 相關(guān)問題記錄

$ git push origin master
git@gitee.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

需要設(shè)置公鑰:

 ssh-keygen -t rsa -C 'zhuhuitao_struggle@163.com'

生成公鑰
$ git push -u origin master
To gitee.com:SixtecCloud/sixtec-cloud-android-repo.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'gitee.com:SixtecCloud/sixtec-cloud-android-repo.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.

$ git pull origin master
remote: Enumerating objects: 2778, done.
remote: Counting objects: 100% (2778/2778), done.
remote: Compressing objects: 100% (1836/1836), done.
remote: Total 2778 (delta 847), reused 2772 (delta 847), pack-reused 0
Receiving objects: 100% (2778/2778), 55.85 MiB | 10.21 MiB/s, done.
From gitee.com:SixtecCloud/sixtec-cloud-android-repo
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
fatal: refusing to merge unrelated histories

當(dāng)執(zhí)行完pull后,再次提交:

$ git push -u origin master
To gitee.com:SixtecCloud/sixtec-cloud-android-repo.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'gitee.com:SixtecCloud/sixtec-cloud-android-repo.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.

hint: Updates were rejected because the tip of your current branch is behind

出現(xiàn)這個錯誤的原因是git本地倉庫的當(dāng)前版本低于遠(yuǎn)程倉庫的版本(大白話就是:你在github上進行的修改沒有同步到本地git倉庫中)。

在終端下輸入:git push -u origin master -f
這句話執(zhí)行的后果就是在遠(yuǎn)程倉庫中進行的相關(guān)修改會被刪除,使遠(yuǎn)程倉庫回到你本地倉庫未修改之前的那個版本,
然后上傳你基于本地倉庫的修改。這如果在企業(yè)開發(fā)中就會讓別的程序員的這些天的開發(fā)付之東流,一切回到解放前。

相關(guān)解決辦法:
https://blog.csdn.net/IT_SoftEngineer/article/details/107133313

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容