- 初始化本地git仓库
- git init
- 创建远端git仓库
- 创建远程仓库 (github页面创建)
- 建立本地仓库和远端仓库联系
- 查看是否已经建立联系
- git remote -v
如下表示已经建立联系
origin git@github.com:xxx(fetch)
origin git@github.com:xxx (push) - 删除联系
git remote remove origin - 建立联系
git remote add origin git@github.com:xxx/xxx.git
- git remote -v
- 遇到的问题
- The authenticity of host ‘github.com (20.205.243.166)’ can’t be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
Are you sure you want to continue connecting (yes/no)?
直接yes,会生成known_hosts文件,在用户./ssh目录下
- The authenticity of host ‘github.com (20.205.243.166)’ can’t be established.
- push到远端
- git push origin xxx
- git@github.com: Permission denied (publickey). fatal: Could not read from remote repository
秘钥设置不对的问题
- 生成ssh key
- ssh-keygen -t rsa -C “youremail@example.com”
- 用户目录下会生成id_rsa 和id_rsa.pub
- 将id_rsa.pub内容拷贝到git
- git@github.com: Permission denied (publickey). fatal: Could not read from remote repository