git clone
两种方式clone远程仓库到本地。
通过ssh
命令格式:
git clone git@xxxxxx.git
使用这种方法需要提前创建ssh秘钥。
- 首先打开一个git控制台,输入命令 ssh-keygen -t ed25519 -C “xxxxx@xxxxx.com”
- 输入命令后需要点击四次回车,其中第一次回车是确认秘钥存放路径的,一般默认就好,默认实在(C:\Users\username.ssh\)。看不到的话设置一下隐藏项目可见
- 之后将id_rsa.pub文件内的全部内容拷贝(公钥)
- 登录网上的git,个人设置->ssh秘钥->将拷贝的公钥内容粘贴上去->添加ssh秘钥。
- git clone git@xxxxxx.git就可以免密克隆了
通过http
git clone http://xxxxx.git
这种方式不需要使用和配置ssh秘钥。但是每次登录都需要输入用户名和密码。
用户配置
用户配置分为两种,全局用户和本地用户
全局用户适用于本电脑上所有仓库,本地用户只有在某一个仓库内可以配置,只用于哪一个仓库。
全局用户配置
git config --global user.name "GitHub上使用的用户名"
git config --global user.email "GitHub上的使用的邮箱账号"
git config --global --list //查看
本地用户配置
git config user.name "GitHub上使用的用户名"
git config user.email "GitHub上的使用的邮箱账号"
git config --list //查看