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。
解決這個問題的辦法是:
- 在終端輸入
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