一、下载git并安装
git下载地址:https://gitforwindows.org/
阿里code地址:https://code.aliyun.com/
二、添加Git用户名并设置邮箱
//检查Git是否已经安装
git --version
//添加用户名并验证该配置是否正确
git config --global user.name 1104404103
git config --global user.name
//设置邮箱地址并验证邮箱设置是否正确
git config --global user.email 1104404103@qq.com
git config --global user.email
//验证前面做的那些配置
git config --global --list
//判断是否已经存在本地公钥(获取你生成的公钥)
cat ~/.ssh/id_rsa.pub
//生成ssh key
ssh-keygen -t rsa -C "1104404103@qq.com"
复制这个公钥放到你的个人设置中的SSH/My SSH Keys下,请完整拷贝从ssh-
开始直到你的用户名和主机名为止的内容。
四、Git基本命令
//将文件夹变成本地仓库
git init
//将新仓库和本地git相关联(origin表示远程仓库的代名称)
git remote add origin git@code.aliyun.com:1104404103/mytest.git
//添加文件
git add .
//提交
git commit -m "message"
//同步到远程仓库(在第一次同步的时候,必须使用如下指令)
git push -u origin master
//以后的推送直接使用
git push origin master
git add -A 提交所有变化
git add -u 提交被修改的文件和被删除的文件,不包括新文件
git add . 提交新文件和被修改的文件,不包括被删除的文件
//取消仓库与本地git的关联
git remote remove origin
//克隆项目(第一次使用)
git clone git@code.aliyun.com:1104404103/mytest.git
//下载项目的最新更改
git pull origin master
推荐学习资料: 廖雪峰的官方网站