一、创建分支
git branch 分支名称

此时创建的分支为本地分支,需提交到github上,运行下行命令进行同步
git push origin 分支名称

从本地拉取远程分支
git fetch origin 分支名称
二、切换分支
git checkout 要切换到的分支名称

创建并切换分支
git checkout -b 分支名称 (相当于执行了创建和切换两个命令)

当前分支下无法删除该分支!!!
三、查看
1、查看本地分支
git branch

2、查看远程分支
git branch -r

3、查看所有分支
git branch -a
四、合并分支
例如 test分支合并到master分支,当前分支必须处于master分支上 运行如下命令
git merge test

五、删除分支
1、删除本地分支
git branch -d 分支名称

2、删除远程分支
git push origin --delete 分支名称

网友评论