1. 程式人生 > >git常見的一些錯誤:fatal: Could not read from remote repository. fatal: Not a git repository (or any of the

git常見的一些錯誤:fatal: Could not read from remote repository. fatal: Not a git repository (or any of the

錯誤一:fatal: Not a git repository (or any of the parent directories): .git

此錯誤是因為你當前所在的資料夾還沒有git成本地倉庫,確保你是在作為本地倉庫的資料夾下,然後使用:git init

 

錯誤二:

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

此錯誤是你還關聯遠端倉庫時使用的地址不正確,如果你是關聯你的遠端倉庫可以使用Https,但如果你關聯的遠端倉庫只能使用ssh地址,那你要在遠端倉庫新增你的ssh金鑰。如果你沒有ssh key,那就先建立

1.建立SSH Key
在終端輸入(輸入完成後回車幾下):ssh-keygen -t rsa -C "GitHub的郵箱地址"


2.切換到~/.ssh目錄下
cd 路徑(上面命令的輸出的內容有完整的路徑,我的是/home/lihongcheng/.ssh)
用ls命令可以檢視此目錄下的檔案有id_rsa(私鑰)和id_rsa.pub(公鑰)


3.顯示公鑰
cat id_rsa.pub
然後把顯示出的私鑰貼上放到一個檔案(此步可以不做)