一、配置用户信息
git config --global user.name "admin"
git config --global user.email admin@git.com
二、查看配置信息
git config --list
三、创建仓库
1、使用当前目录作为Git仓库,我们只需使它初始化。
2、该命令执行完后会在当前目录生成一个 .git 目录。
git init
1、使用我们指定目录作为Git仓库。初始化后,会在 newrepo 目录下会出现一个名为 .git 的目录,所有 Git
2、需要的数据和资源都存放在这个目录中。
git init newrepo
四、克隆仓库
//当前目录
git clone git://github.com/schacon/grit.git
//指定目录
git clone git://github.com/schacon/grit.git mygrit
//指定分支
git clone -b develop git://github.com/schacon/grit.git
//指定版本库深度
git clone -b develop git://github.com/schacon/grit.git --depth 1
//调整为完整版本库
git fetch --unshallow
五、ssh配置
1、进入git bash执行
ssh-keygen -t rsa -C "admin@git.com"
1、admin@git.com 替换成你的电子邮件
2、然后敲3次回车,生成完毕
3、生成秘钥文件位置:Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
2、查看秘钥
cat ~/.ssh/id_rsa.pub
3、Windows复制到剪贴板
clip < ~/.ssh/id_rsa.pub
3、复制秘钥到git网站后台
六、使用git clone
//进入指定目录
git clone -b develop git@code.aliyun.com:schacon/grit.git
七、常见问题
1、阿里云 ssh无法克隆问题
异常:Unable to negotiate with **** port 22: no matching host key type found. Their offer: ssh-rsa
解决方法:
在~/.ssh/目录下,创建config文件(config没有后缀)添加如下信息
Host *
HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa
2、小乌龟使用ssh
将ssh客户端,修改成git下的ssh.exe