| git init |
初始化 |
| git config –global user.email “xxx@xx.xx” |
配置邮箱为xxx@xx.xx |
| git config –global user.name “xxxx” |
配置用户为xxxx |
| |
|
| git clone address |
从address中获取最新代码合到本地 |
| |
|
| git remote |
查询当前git的远程名称 |
| git remote -v |
查询当前git的远程名称和地址 |
| |
|
| git branch |
查看本地分支 |
| git branch -r |
查看远程分支 |
| git branch -a |
查看所有分支 |
| git checkout -b test01 |
创建并切换到分支test01 |
| git branch test01(分支名) |
创建分支test01 |
| git checkout test01(分支名) |
切换到分支test01 |
| git checkout master |
切换到master分支 |
| git merge test01 |
将test01分支合并到master(当前活动分支,用checkout切换,可以用git branch查看分支前有星号的是当前活动分支) |
| git branch -d test01 |
删除使用完的分支test01 |
| |
|
| git status |
查看工作区代码相对于暂存区的差别 |
| git diff file |
比较还未提交的文件,file可以从git status中复制取得;或者比较项目中任意两个版本的差异,具体再查 |
| git add . |
将当前目录下修改的所有代码从工作区添加到暂存区 . 代表当前目录 |
| git add 文件名 |
将当前目录下修改的指定文件从工作区添加到暂存区,file代表具体的文件名,可以从git status中复制得到 |
| git commit -m “注释” |
将暂存区文件提交到版本库分支 |
| git push origin master |
将本地分支master推送到远程origin |
| |
|
| git log |
查看提交记录 |
| git log -p -2 |
比较最近两次的提交差异 |
| |
|
| git stash list |
查看指定区域存储记录 |
| git stash pop |
将指定区域的记录拿回工作区 |
| git stash |
将当前工作区域所有修改的内容存到指定区域.工作区还原到未修改状态 |
| |
|
| git reset –hard 版本ID |
回滚到指定版本 |