安装Git
在Windows上安装Git
从Git官网直接下载安装程序,按默认选项安装即可。
配置Git
使用git config,有3级
一、系统:/etc/gitconfig 文件
1 | $ git config --system user.name "Your Name" |
二、全局用户:~/.gitconfig
1 | $ git config --global user.name "Your Name" |
三、当前使用仓库:.git/config
1 | $ git config --global user.name "Your Name" |
创建SSH Key
$ ssh-keygen -t rsa -C "youremail@example.com"
用户主目录下生成.ssh目录,里面有id_rsa和id_rsa.pub两个文件,这两个就是SSH Key的秘钥对,id_rsa是私钥,不能泄露出去,id_rsa.pub是公钥,可以放心地告诉任何人。
添加远程仓库添加id_rsa.pub里面的内容。
添加远程仓库
从本地关联远程:git remote add origin git@github.com:example/example.git
克隆远程库:git clone git@github.com:example/example.git