git使用
首先git是分布式版本控制系统
git初始用
-
设置一个身份标识
-
$ git config --global user.name "Your Name"
-
$ git config --global user.email "email@example.com"
-
创建版本库
- 选择一个合适的位置创建一个空目录
$ cd /e/git
$ mkdir learngit //创建一个仓库
- 将仓库变为git可管理仓库
git init
使用git
$ git add test.txt //告诉git 把文件添加到仓库中
$ git commit -m "wrote a test file" //-m 后面是本次提交的说明
另外可以提交多个 然后一起使用commit命令
对接远程仓库 github
- 创建SSH KEy
$ ssh-keygen -t rsa -C "youremail@example.com"
然后在github中保存
- 添加一个远程库
- 进行连接
$ git remote add origin git@github.com:iszhonghu/springboot-testdemo.git
本地内容推送上去
$ git push -u origin master
推送步骤
echo “# springboot-testdemo” >> README.md
git init
git add README.md
git commit -m “first commit”
git remote add origin https://github.com/iszhonghu/springboot-testdemo.git
git push -u origin master
其他操作命令
git clone (地址) 下载
git status 查看是否还有的没交的
git diff (查看改变了那个文件的什么内容)
git log 查看日志