Git初始配置和常用命令
Git安装
安装包下载:Git - Downloading Package (git-scm.com)
设置用户名和邮箱
主要是为了与远程仓库(https://github.com/)建立连接,先设置好用户名和邮箱(跟github
上的一致)
git config --global user.email "注册邮箱"
git config --global user.name "注册名"
生成SSH
建立和远程仓库的链接。
ssh-keygen -t rsa -C "注册邮箱"
然后一直按Enter
就可以了。注意ssh key
保存的位置,有两个,一个是私有一个是公有(pub)。
Github配置SSH
登录Github
账户,在设置中找到SSH and GPG keys
,然后用文本文档打开公有的ssh key
,然后复制密钥粘贴到Github
里面,完成。
代理设置
由于Github
的使用需要代理,这个时候直接用Git
软件还不能下载Github
上的项目。先关闭原来的代理:
git config --global --unset http.proxy
git config --global --unset https.proxy
然后添加代理软件Clash
的代理端口:
git config --global http.proxy http://127.0.0.1:xxxx
git config --global https.proxy https://127.0.0.1:xxxx
然后就可以正常下载Github
上的项目了:
git clone http://xxx.xxx.git