Git中push操作異常
2023-06-26 20:40 作者:四方風(fēng)biubiu | 我要投稿

問題描述:
Git練習(xí)中將本地庫文件push到遠(yuǎn)程庫時出現(xiàn)如上異常,顯示需要確認(rèn)是否有正確的訪問權(quán)限并且確認(rèn)遠(yuǎn)程庫是否存在。
解決辦法:
1、首先需要知道在git設(shè)置的名字和郵箱,忘了就重新設(shè)置
git config --global user.name "用戶名"? ?//設(shè)置用戶名
git config --global user.email "郵箱"? //設(shè)置郵箱
2、刪除.ssh文件夾下的known_hosts文件
文件位置在c盤/Users/用戶/.ssh下,手動刪除即可
3、Git輸入命令
ssh-keygen -t rsa -C "郵箱"
4、后續(xù)出現(xiàn):
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):
回車即可,看清日志反饋,可能需要細(xì)微調(diào)整
5、.ssh下自動生成id_rsa和id_rsa.pub兩個文件,記事本打開id_rsa.pub,全部內(nèi)容復(fù)制
6、GitHub設(shè)置——》SSH and GPG keys ——》New SSH key
名字不重要,把復(fù)制內(nèi)容粘貼到key中
key type默認(rèn)即可
7、至此完成,重新push即可
標(biāo)簽: