Git本地分支关联远程分支
本地分支相关操作
-
查看本地分支
shellgit branch -
新建本地分支
shellgit branch name -
切换本地分支
shellgit checkout name -
新建本地分支并切换到该分支
shellgit checkout -b name #或 git branch name -
删除本地分支
shellgit branch -d name git branch -D name #强制删除
远程分支相关操作
-
查看远程和本地所有分支
shellgit branch -a -
新建远程分支
shellgit checkout -b localname #首先在本地新建分支 git push origin localname:remotename #将本地分支同步到远程,完成新建远程分支 -
本地分支连接远程分支
shellgit branch --set-upstream-to=origin/remotename #或 git branch -u origin/remotename -
根据远程分支新建本地分支
shellgit checkout -b name origin/remotename #或 git branch --set-upstream-to=origin/remotename localname -
删除远程分支(慎重)
shellgit push origin :remotename #或 git push origin --delete remotename