注意:一般本地分支local_branch和远程分支remote_branch名称保持一致
创建本地分支
创建本地分支并切换
git checkout -b local_branch
相当于
创建本地分支
git branch local_branch
切换到新建分支
git checkout local_branch
查看分支
查看本地分支
git branch
查看远程分支
git branch -r
查看本地和远程分支
git branch -a
拉取远程分支到本地
git checkout -b local_branch origin/remote_branch
推送本地分支到远程
推送本地分支local_branch到远程分支remote_branch并建立关联关系
远程已有remote_branch分支,并已关联本地local_branch分支
git push
远程已有remote_branch分支,但未关联本地local_branch分支
git push -u origin/remote_branch
远程尚未创建remote_branch分支
git push -u origin local_branch:remote_branch
删除分支
删除本地分支
git branch -d|-D local_branch
删除远程分支
git push origin :remote_branch git branch -d -r remote_branch
关联分支
git branch --set-upstream local_branch origin/remote_branch
合并分支
合并某个分支当当前分支
git merge other_branch
分支重命名
git branch -m|-M old_branch new_branch