git branch -a 查看所有分支
git branch 查看当前分支
git checkout 分支名 切
安装Git
[zhao@root]$sudo apt-get install查看版本号
[zhao@root]$git --version
2全局配置git
[zhao@root]$git config --global user.name zhaoliang
[zhao@root]$git config --global user.email zhaoliang@163.com
[zhao@root]$git config --global color.ui true //字体颜色
配置完列出配置信息
[zhao@root]$git config --list
查看配置 也可以对这个文件修改
[zhao@root]$cat -/.gitconfig
3创建 repository
创建一个空的repository
[zhao@root]$git init
克隆repository
[zhao@root]$git clone https//github.com/dfid
4 添加及提交文件
查看状态
[zhao@root]$git status
添加文件
[zhao@root]$git add code.py
查看状态
[zhao@root]$git status
提交
[zhao@root]$git commit -m 'init commit'
查看状态
[zhao@root]$git status
查看状态
[zhao@root]$git status -s
查看文件差别
[zhao@root]$git diff
[zhao@root]$ git diff --staged
[zhao@root]$git diff HEAD
撤销误操作
[zhao@root]$git reset code.py //第三到第二
[zhao@root]$git checkout code.py 第二到第一
[zhao@root]$git checkout HEAD code.py //第三到第一
移除及重命名文件
[zhao@root]$git rm old.py //删除
[zhao@root]$git commit -m 'delete old.py'
[zhao@root]$git rm --cached code.py
[zhao@root]$git mv README.txt README.md //重命名
[zhao@root]$git commit -m 'rename README'
暂存工作区
[zhao@root]$git stash
[zhao@root]$git stash list //查看暂存区
[zhao@root]$git stash pop //还原暂存区里的东西
图解commit对象
创建及删除分支
git branch tryideazhao //创建分支
git checkout tryideazhao //切换分支
git branch //查看在那个分支上