git常用操作指令

git操作
master : 默认开发分支;
origin : 默认远程版本库

添加远程仓库:git remote add [name] [url]  通常name为origin

克隆远程仓库:git clone [url]

本地分支
创建并切换分支:git checkout -b <name>
创建但不切换分支: git branch <name>
切换分支:git checkout <name>
删除分支:git branch -d <name>
查看分支:git branch
同步远程仓库代码到本地:git pull [name]

远程分支
查看远程分支: git branch -a
将分支test推到远程分支,即创建远程分支:git push origin test
在远程仓库新建分支后,从远程仓库更新信息:git fetch origin
查看分支与跟踪情况:git remote show origin(尤其是新建了远程分支后,看其状态是否是tracked)
删除远程分支:
git branch -r -d origin/branch-name
git push origin :branch-name

git中文件的状态分类:
committed:已提交
staged:已暂存
modified:已修改
ignored:不纳入版本跟踪状态

图片转自:http://www.cnblogs.com/1-2-3/archive/2010/07/18/git-commands.html

原文地址:https://www.cnblogs.com/lyy-2016/p/5909855.html