设置用户名和邮箱
(--global为全局参数,表明本地所有Git仓库都会使用这个配置)
git config --global user.name "yourname"
git config --global user.email "your_email@youremail.com"
配置SSH密钥
1.检查检查本机是否有ssh key设置
$ cd ~/.ssh 或cd .ssh
若本机没有则提示:
ssh-keygen -t rsa -C "your_email@youremail.com"
3.添加密钥(SSH key),并验证是否成功
连接远程仓库
下面两种方式都可以
git remote add origin git@github.com:yourName/repositoryname.git
git remote add origin https://github.com/yourName/repositoryname.git