创建本地仓库
git init
查看一个文件的状态
git status
查看本地分支
git branch
从当前分支切换到其他分支
git checkout <branch-name>
创建新分支并切换到新分支
git checkout -b <branch-name>
删除分支
git branch -d <branch-name>
合并分支(将分支合并到当前分支)
git merge <branch-name>
全部上传到缓存区
git add .
提交到本地仓库
git commit -m 'some message'
提交到远程仓库 提交到远程指定分支
git push git push staging
远程仓库重新命名
git remote rename old new
拉取远程仓库 拉取远程指定分支
git pull git pull staging
克隆
git clone 地址
获取历史版本号
git reflog
回退到某个版本号
git reset --hard 版本号
具体流程
1、打开cmd 输入git ,如果输出一大串信息,说明已经安装了git ,否则没有安装,那么先去官网安装
2、安装完成,右击桌面空白处---git --git bash 进行配置
3、配置信息(配置用户名和邮箱)
git config --global user.name "Your Name"
git config --global user.email "email@example.com"
4、创建本地仓库
git init
本地仓库与远程仓库连接
git remote add origin 自己的远程仓库地址
第一次推送到master必须加u
git push -u origin master
从当前分支创建新分支并切换到新分支
git checkout -b dev_1.0
在dev_1.0分支进行操作后
查看状态
git status
全部上传到缓存区
git add .
提交到本地仓库
git commit -m 'some message'
提交到远程仓库
git pull