文件上傳git服務器

fatal:Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
出現(xiàn)這個問題的原因是因為沒有在github賬號添加SSH key。
解決這個問題的辦法是:

  1. 在終端輸入
    ssh-keygen -t rsa -C "username" (注:username為你git上的用戶名)
    執(zhí)行成功,返回
    Generating public/private rsa key pair.
    Enter file in which to save the key (/Users/username/.ssh/id_rsa):
    這里的username是你電腦上的用戶名

Enter passphrase (empty for no passphrase):
直接回車
Enter same passphrase again:
回車

Your identification has been saved in /Users/username/.ssh/id_rsa.
Your public key has been saved in /Users/username/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:ICRwoBNoU6kOLEexOwwR0yFgUXC1yChs5otSeAH2/+4 username
The key's randomart image is:
+---[RSA 2048]----+
|&XX+. |
|
XB=. . | 一堆
|B=+... |
|BB.o.. . |
|=o
. S |
|.+.. . |
|o. . |
|. . |
| .E |
+----[SHA256]-----+
最后執(zhí)行cat命令查看文件的內容:
cat /Users/username/.ssh/id_rsa.pub

這時候會看見
ssh-rsa AAAAB3Nza吧啦吧啦

復制到git的add SSH key里面進行添加

cd 到工程目錄
git init

git remote add origin git@地址.git

如果出現(xiàn)fatal: remote origin already exists.
輸入 git remote rm origin

git add .

git commit -m "initial commit"

git push -u origin master

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

相關閱讀更多精彩內容

友情鏈接更多精彩內容