添加远程仓库
添加远程仓库-Github为例
基本命令:
git remote add [shortname] [url]
- 以Github为例,本地Git仓库和Github仓库之间的传输时通过SSH加密的,所以需要配置验证信息,使用以下命令生成SSH Key:
ssh-keygen -t rsa -C "[email protected]" # 邮箱地址为你在github注册的邮箱
- 上述命令将在
C:\Users\当前用户名\.ssh
目录下(Linux用户在~/.ssh
),生成id_rsa.pub
文件,该文件记录了所生成的密钥。 - 在github账户的settings中找到
SSH and GPG keys
,点击New SSH key
,将刚刚生成的密钥复制进来,保存即可。 - 验证是否成功,输入以下命令:
$ ssh -T [email protected]
The authenticity of host 'github.com (20.205.243.166)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes # 输入yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
Hi Yelrahc-sudo! You've successfully authenticated, but GitHub does not provide shell access. # 成功信息
- github上新建仓库
点击创建后,你有三种方式来初始化你创建的仓库