git常规使用的命令

注: xxxx代表你的分支名称
 
1:本地新建一个分支,与远程分支关联:
git branch --set-upstream-to origin/xxxx xxxx
 
2:创建本地分支:
git  branch xxxx
 
3:切换本地分支:
git checkout xxxx
 
4:创建,并切换到新的分支:
git checkout -b xxxx
 
5:远程已有remote_branch分支但未关联本地分支local_branch且本地已经切换到local_branch
git push -u origin/remote_branch
 
6:远程没有有remote_branch分支并,本地已经切换到local_branch
 git push origin local_branch:remote_branch
 
7:删除本地分支local_branch
 git branch -d local_branch (git branch -d | -D branchname )
 
8:删除远程分支remote_branch
 git branch -d -r branchname 删除远程branchname分支
 
9:分支重命名: 
git branch -m | -M oldbranch newbranch 重命名分支,如果newbranch名字分支已经存在,则需要使用-M强制重命名,否则,使用-m进行重命名。
 
10.查看本地分支
git branch
 
11.查看远程和本地分支
 git branch -a
原文地址:https://www.cnblogs.com/tom-plus/p/6632428.html