天天看點

Git fatal: Authentication failed for

一、錯誤

fatal: Authentication failed for

$ git push -u origin master
fatal: Authentication failed for 'https://code.aliyun.com/***/***.git/'
           

二、網上的解決方法(個人記錄一下)

1.配置郵箱和使用者名

$ git config --global --replace-all user.email “輸入你的郵箱”

$ git config --global --replace-all user.name “輸入你的使用者名”

這個方法在mac上确實是行得通的,但是如果是windows 好像不太好使,

我執行之後還是一樣的問題!

2.打開控制台删除憑據

選擇使用者賬戶

Git fatal: Authentication failed for

管理windows憑據

Git fatal: Authentication failed for

然後删除相應的git憑據

Git fatal: Authentication failed for

但是這個方法并沒有解決我的這個問題!!!

三、錯誤原因

由于我用的是公司的code.aliyun的賬号,然而我并沒有生成和配置這個賬号的Git公鑰

四、解決方法

1、配置賬戶名和郵箱

$ git config --global --replace-all user.name “輸入你的使用者名”

或($ git config --global user.name “使用者名”)

$ git config --global --replace-all user.email “輸入你的郵箱”

或($ git config --global user.email “郵箱”)

2、根據郵箱生成該賬号的公鑰

ssh-keygen -t rsa -C “郵箱”

3、找到C:/Users/1/.ssh/id_rsa.pub檔案

複制id_rsa.pub檔案裡的内容(公鑰)配置到Git賬号的公鑰即可!